Both configurations of package.json
hare equally valid:
npm test
will run linting and then testing:
"test": "jshint . && mocha",
npm test
will still run linting and then testing:
"pretest": "jshint",
"test": "mocha",
... BUT it is NOT possible to invoke npm pretest
directly from the command line ... aha! But I recently read:
## All scripts under scripts can be executed with npm run-script [script name].
# Like this, to run our test command:
npm run-script pretest
npm run-script test
# `run` and `run-script` are aliased
npm run pretest
npm run test
- If you pass -- (there’s a space after the --, right there) you can pass argument through to the underlying command.
## http://www.marcusoft.net/2015/08/npm-scripting-configs-and-arguments.html#passing-through-command-line-argument
# So if you have:
# "scripts": { "test": "mocha" }
# then running:
npm run test -- --debug-brk
# is like running `mocha --debug-brk`