量角器选项在 package.json 脚本中不起作用 [英] Protractor option does not work in package.json script
本文介绍了量角器选项在 package.json 脚本中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下命令按预期工作:
protractor --cucumberOpts.tags='not @tag1' conf.js
现在我想将此命令作为 script
添加到 package.json
中,如下所示:
Now I want to add this command as a script
to package.json
like this:
"scripts": {
"my-script": "protractor --cucumberOpts.tags='not @tag1' conf.js"
}
运行命令 npm run my-script
给我以下错误:
Running the command npm run my-script
gives me the following error:
Usage: protractor [configFile] [options]
configFile defaults to protractor.conf.js
The [options] object will override values from the config file.
See the reference config for a full list of options.
Options:
...
Error: Error: more than one config file specified
这是为什么?
这两个命令似乎是相同的.
Both of the commands seem to be identical.
推荐答案
这实际上不是量角器问题.我能够重新创建这个问题并通过在该脚本字符串中使用转义双引号来解决它,就像这样.
This is not actually a protractor issue. I was able to recreate this issue and resolved it by using escaped doubles quotes in that script string like so.
"scripts": {
"my-script": "protractor --cucumberOpts.tags=\"not @tag1\" conf.js"
}
这个问题(显然)与 node 如何处理不同操作系统上的单引号有关.这个问题中有更多信息.
This issue (apparently) is to do with how node handles single quotes on different operating systems. There is some more info in this question.
这篇关于量角器选项在 package.json 脚本中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文