npm run传递参数

karma.conf.js使用以下设置时,unit test会不停地跑。

autoWatch: false,
singleRun: true,

想只跑一次,发现命令行参数不起效果。

npm run ng test --watch=false --code-coverage

原来需要加--,这是npm传递参数给script的方法。

npm run ng test -- --watch=false --code-coverage

npm help run查看详细说明。

As of npm@2.0.0, you can use custom arguments when executing scripts. The special option – is used by getopt to delimit the end of the options. npm will pass all the arguments after the – directly to your script:

npm run test – --grep=“pattern”

The arguments will only be passed to the script specified after npm run and not to any pre or post script.

不过不应该整天打这么长的命令行,复杂的命令都应该放到script里。

package.json

"test": "ng test --watch=false --code-coverage",

然后npm test就可以。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值