best way to catch arguments #263
Answered
by
onedr0p
vjonas
asked this question in
Help needed
-
Hey all What would be the best way to catch variables passed in on the script.mjs file? Cheers |
Beta Was this translation helpful? Give feedback.
Answered by
onedr0p
Jul 20, 2022
Replies: 4 comments 5 replies
-
It depends. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Could you provide an example on how to get the parameter in the js code? |
Beta Was this translation helpful? Give feedback.
5 replies
-
You can do this something like: const action = argv["action"] || process.env.ACTION
const app = argv["app"] || process.env.APP
const namespace = argv["namespace"] || process.env.NAMESPACE
if (!app) { throw new Error("Argument --app or envirornment variable APP not set") }
if (!namespace) { throw new Error("Argument --namespace or envirornment variable NAMESPACE not set") }
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
vjonas
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can do this something like:
./thing.mjs --action blah ....