I basically took this bash recipe to run different commands based on whether a package.json
script is called with or without a parameter...
"scripts": {
"paramtest": "if [ -z $1 ]; then echo \"var is unset\"; else echo \"var is set to {$1}\"; fi",
...
Calling without a parameter works as expected:
$>yarn paramtest
var is unset
$>npm run paramtest
var is unset
$>
Calling with a parameter gives me an error:
$>yarn run paramtest foo
/bin/sh: 1: Syntax error: word unexpected
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
$>npm run paramtest -- foo
> photocmd@0.0.7 paramtest /depot/own/photocmd
sh: 1: Syntax error: word unexpected
...