Home

Awesome

nps-utils

Utilities for nps (npm-package-scripts)

Build Status Code Coverage Dependencies version downloads MIT License

All Contributors PRs Welcome Donate Code of Conduct Roadmap Examples

Watch on GitHub Star on GitHub Tweet

<a href="https://app.codesponsor.io/link/PKGFLnhDiFvsUA5P4kAXfiPs/kentcdodds/nps-utils" rel="nofollow"><img src="https://app.codesponsor.io/embed/PKGFLnhDiFvsUA5P4kAXfiPs/kentcdodds/nps-utils.svg" style="width: 888px; height: 68px;" alt="Sponsor" /></a>

The problem

nps is a great package to empower your scripts and there are some common things you wind up doing to keep your package-scripts.js file clean, useful, and maintainable. So you wind up duplicating utility functions across projects.

This solution

This has several utility functions you'll often want when using nps.

Check out what the concurrent and runInNewWindow methods can do:

<a href="https://github.com/kentcdodds/nps-utils/raw/master/other/nps-utils-demo.gif" title="Pull out npm scripts into another file with nps"> <img src="https://github.com/kentcdodds/nps-utils/raw/master/other/nps-utils-demo.gif" alt="concurrent gif" title="concurrent gif" width="700" /> </a>

Installation

This module is distributed via npm which is bundled with node and should be installed as one of your project's devDependencies:

npm install --save-dev nps-utils

Usage

You'll most likely use this in your package-scripts.js file:

const npsUtils = require('nps-utils')

module.exports = {
  scripts: {
    validate: npsUtils.concurrent.nps('lint', 'build', 'test --coverage'),
    lint: 'eslint .',
    build: 'webpack --env.production',
    test: 'jest'
  }
}

Available methods:

API docs can be found here

nps also exports common-tags as commonTags which can be really helpful for long scripts or descriptions.

Or, see the JSDoc right in the source code 😎

Inspiration

This package was inspired by the removal of --parallel from p-s here.

Other Solutions

I am unaware of other solutions, but if you come across any, please add a PR to list them here!

Contributors

Thanks goes to these people (emoji key):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;"/><br /><sub>Kent C. Dodds</sub><br />💻 📖 🚇 ⚠️<img src="https://avatars2.githubusercontent.com/u/7352279?v=3" width="100px;"/><br /><sub>Huy Nguyen</sub><br />📖 🚇<img src="https://avatars1.githubusercontent.com/u/1970063?v=4" width="100px;"/><br /><sub>Keith Gunn</sub><br />🐛 💻 📖 ⚠️<img src="https://avatars3.githubusercontent.com/u/215033?v=4" width="100px;"/><br /><sub>Mike Cann</sub><br />💻 ⚠️
<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the all-contributors specification. Contributions of any kind welcome!

LICENSE

MIT