npm script workflow
Opened this issue · 0 comments
genkio commented
bits and pieces of npm script workflow for turbo boosting your productivity.
Quick start a npm project.
$ npm config set init.author.email ""
$ npm config set init.author.name "Ji Wu"
$ npm config set init.author.url "http://github.com/j1wu"
$ npm config set init.license "MIT"
$ npm config set init.version "0.1.0"
$ npm init -f
Run npm scripts in parallel
Replace &&
with &
to connect commands, or use the npm-run-all
library.
...
"test": "npm-run-all --parallel lint:* ava"
...
Use pre and post hook to perform tasks before or after certain script
...
"pretest": "npm run lint",
"test": "ava tests/"
...
"precover": "rm -rf coverage",
"cover": "nyc --reporter=html npm test",
"postcover": "rm -rf .nyc_output && opn coverage/index.html"
Use custom variables
"config": {
"port": 3000
},
"scripts": {
"cover:serve": "http-server coverage_archive/$npm_package_version -p $npm_package_config_port",
}