【发布时间】:2019-03-15 04:04:50
【问题描述】:
我基本上是 took this bash recipe 来运行不同的命令,这取决于 package.json 脚本是否带参数调用...
"scripts": {
"paramtest": "if [ -z $1 ]; then echo \"var is unset\"; else echo \"var is set to {$1}\"; fi",
...
不带参数的调用按预期工作:
$>yarn paramtest
var is unset
$>npm run paramtest
var is unset
$>
用参数调用给我一个错误:
$>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
...
怎么了?
【问题讨论】: