All the benefits of npm scripts without the cost of a bloated package.json and limits of json
npm install npsAll the benefits of npm scripts without the cost of a bloated package.json and limits of json
> nps is short for npm-package-scripts
[![Build Status][build-badge]][build]
[![Code Coverage][coverage-badge]][coverage]
[![Dependencies][dependencyci-badge]][dependencyci]
[![version][version-badge]][package]
[![downloads][downloads-badge]][npm-stat]
[![MIT License][license-badge]][license]

[![PRs Welcome][prs-badge]][prs]
[![Donate][donate-badge]][donate]
[![Code of Conduct][coc-badge]][coc]
[![Roadmap][roadmap-badge]][roadmap]
[![Examples][examples-badge]][examples]
[![nps friendly][nps-badge]](#badge)
Even though npm scripts have a ton of advantages ([learn more][scripts-advantages]), it can grow into an
[unmaintainable mess][mess] in your package.json file. Part of the problem is we're configuring scripts in json
which has fundamental issues (like no comments).
nps is a package that solves this problem by allowing you to move your scripts to a package-scripts.js file. Because
this file is a JavaScript file, you can do a lot more with your project scripts. Here's an example of apackage-scripts.js file:
``javascript
const npsUtils = require("nps-utils"); // not required, but handy!
module.exports = {
scripts: {
default: "node index.js",
lint: "eslint .",
test: {
// learn more about Jest here: https://facebook.github.io/jest
default: "jest",
watch: {
script: "jest --watch",
description: "run in the amazingly intelligent Jest watch mode"
}
},
build: {
// learn more about Webpack here: https://webpack.js.org/
default: "webpack",
prod: "webpack -p"
},
// learn more about npsUtils here: https://npm.im/nps-utils
validate: npsUtils.concurrent.nps("lint", "test", "build")
}
};
`
Or in case you prefer YAML, here's an example of how that would look in a package-scripts.yml file:
`yml`
scripts:
default: node index.js
lint: eslint .
test:
# learn more about Jest here: https://kcd.im/egghead-jest
default: jest
watch:
script: jest --watch
description: run in the amazingly intelligent Jest watch mode
build:
default: webpack
prod: webpack -p
validate: concurrent "nps lint" "nps test" "nps build"
To use nps, it's recommended that you either install it globally (npm i -g nps) or add ./node_modules/bin to your$PATH (be careful that you know what you're doing when doing this, find out how here).
Then you can run:
`console`
nps help
Which will output:
`console
Usage: nps [options]