10

我用 nodejs 编写了一个小型命令行程序,我希望能够npm run test使用以下参数键入和运行该程序。

直接输入以下命令即可, node.exe scrappee.js -u 'https://github.com/matutter/{}' -us 'cloggie, AirRocks-Flightcontroller' -s '$commit=li.commits > a > span, $sha=.right .commit-tease-sha' -pm .\test\example_parse_module.js

但是我的 package.json 的内容如下所示,没有任何输出。

"scripts": {
    "test" : "node.exe scrappee.js -u 'https://github.com/matutter/{}' -us 'cloggie, AirRocks-Flightcontroller' -s '$commit=li.commits > a > span, $sha=.right .commit-tease-sha' -pm .\\test\\example_parse_module.js"
}

如何获得npm run test使用这些参数运行 scrappee.js 脚本的命令?

4

1 回答 1

20

问题是单引号'在转发参数时被 npm 转换为“'”,解决方案是用双引号替换它们,如下所示。

"test" : "node.exe scrappee.js -u \"https://github.com/matutter/{}\" -us \"cloggie, AirRocks-Flightcontroller\" -s \"$commit=li.commits > a > span, $sha=.right .commit-tease-sha\" -pm \".\\test\\example_parse_module.js\""
于 2016-05-28T15:49:51.917 回答