Reputation:
I am looking for away to do something like this:
package.json
...
"scripts":{
"debug_mocha_test":"node-debug ./node_modules/mocha/bin/_mocha --grep ${names}"
}
...
so then at the command line, I can then run something like:
npm run debug_mocha_test --names 'test1'
or whatever
does anyone know how to do this, or is there a better way than this?
For some context, the mocha testing library has a --grep function like so:
Upvotes: 2
Views: 7238
Reputation: 1937
Since npm 2.0.0, it's possible to pass arguments to a script defined in the package.json file (https://github.com/npm/npm/pull/5518). The format is not as clean as one would expect, but it works.
To pass the "foo" parameter to the "start" script:
npm run-script start -- foo=1
So in your case, the script in package.json should be:
"debug_mocha_test":"node-debug ./node_modules/mocha/bin/_mocha --grep"
And you can run it using:
npm run debug_mocha_test -- test1
Upvotes: 1