Skip to content

best way to catch arguments #263

Answered by onedr0p
vjonas asked this question in Help needed
Jan 5, 2022 · 4 comments · 5 replies
Discussion options

You must be logged in to vote

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") }

./thing.mjs --action blah ....

Replies: 4 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@antonmedv
Comment options

@vjonas
Comment options

@antonmedv
Comment options

@vjonas
Comment options

@antonmedv
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by vjonas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants