npm: Custom task to run with package.json

{ "name": "customtasks", "main": "app.js", "scripts": { "prestart": "npm run startDB", "start": "nodemon app.js", "pretest": "npm run startDB", "test": "npm run test:adminDB", "test:adminDB": "node ./tests/testAdminDB.js", "posttest:adminDB": "npm run test:watcherDB", "test:watcherDB": "node ./tests/testWatcherDB.js", "posttest": "npm run stopDB", "poststop": "npm run stopDB", "startDB":"mongod --dbpath ./data --fork --logpath /dev/null && sleep 2", "stopDB":"mongo admin --eval 'db.shutdownServer()' > /dev/null" }, "dependencies": { "express": "^4.13.3", "mongodb": "1.4.x", }, "devDependencies": { "nodemon": "^1.8.1" } }
$npm test #start mongodb > run testAdminDB.js > run testWatcherDB.js > stop db at the end or exit

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.