14

I've written a small command line program with nodejs and I want to be able to type npm run test and run the program with the arguments below.

Typing the following command directly works, 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

But with the contents of my package.json as follows there is no output whatsoever.

"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"
}

How can I get the command npm run test to run the scrappee.js script with the these arguments?

Aage Torleif
  • 1,907
  • 1
  • 20
  • 37

1 Answers1

24

The issue was from the single quote ' being converted to "'" by npm when the arguments are forwarded, the solution was to replace them with double quotes like below.

"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\""
Aage Torleif
  • 1,907
  • 1
  • 20
  • 37
  • if you are using cross-env unfortunately this does not help. Does not work on mac `cross-env-shell mocha --require ts-node/register \"testUnit/**/*.test.ts\""`, still runs tests only if the first subdirectory. Work on mac `mocha --require ts-node/register \"testUnit/**/*.test.ts\""` – Michael Klishevich Feb 04 '20 at 18:58
  • 1
    How did you figure out that single quotes were converted to 2 double quotes? – Derek Greer Jun 04 '20 at 23:24