simple ternaries in npm scripts
npm i -D scrif
to use scrif, add it to npm scripts, e.g.
"start": "scrif dev ? npm run dev : npm run production ?"
then, you can pass strings that match the args in scrif to run the branch, e.g.
npm run start dev
scrif [conditions] ? [branch a] : [branch b] ?
Note that the trailing question mark is required.
You can use any number of search terms but all must match
"cmd": "scrif arg1 arg2 ? ./script-a.sh : ./script-b.sh ?"
will run branch a with: npm run cmd arg1 arg2
but not npm run cmd arg1
You can pass additional args and they will be passed along to both branches
given
"cmd": "scrif a ? ./script-a.sh : ./script-b.sh ?"
npm run cmd foo bar a
will execute ./script-a.sh foo bar
Order doesn't matter, conditions will be removed from args one time. So for instance:
npm run cmd a a
will execute ./script-a.sh a