This can be done in npm@2.1.17
. You don’t specify your OS and the version of npm
that you are using, but unless you have done something to update it, you are probably running npm@1.4.28
which does not support the syntax below.
On Linux or OSX you can update npm with sudo npm install -g npm@latest
. See https://github.com/npm/npm/wiki/Troubleshooting#try-the-latest-stable-version-of-npm for a guide to updating npm
on all platforms.
You should be able to do this by passing an additional argument to your script:
"scripts": {
"test": "mocha --compilers coffee:coffee-script/register --recursive -R list",
"watch": "npm run test -- -w"
}
I verified this using the following, simplified package.json:
{
"scripts": { "a": "ls", "b": "npm run a -- -l" }
}
Output:
$ npm run a
> @ a /Users/smikes/src/github/foo
> ls
package.json
$ npm run b
> @ b /Users/smikes/src/github/foo
> npm run a -- -l
> @ a /Users/smikes/src/github/foo
> ls -l
total 8
-rw-r--r-- 1 smikes staff 55 4 Jan 05:34 package.json
$