grunt-load-npm-run-tasks
A Grunt task loader importing all entries from the scripts
section of package.json
as npmRun:{script-key}
tasks.
Installation
Add the loader to your project:
$ npm i --save-dev grunt-load-npm-run-tasks
Require the loader inside your Gruntfile.js
, like:
module { // ... some tasks definitions etc grunt;};
Example
Say your package.json
contains some commands in the scripts
section, like
"name": "some-project" "scripts": "lint": "eslint --max-warnings 5 path/to/**/*.js" "bundle": "rollup -c" ...
The grunt-load-npm-run-tasks
loader imports those scripts as Grunt tasks npmRun:lint
and
npmRun:bundle
which can then be used like any other task.
Example Gruntfile.js
:
module { 'use strict'; grunt; grunt; grunt; };
npm run --silent
)
Silent mode (By default, all npmRun
Grunt tasks will execute npm run
with the ---silent
option enabled,
in order to prevent irrelevant npm debugging output like
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-appliction@1.0.0 test: \`jest test/\`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-appliction@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
...
You can disable silent mode by adding the {silent: false}
option to the
task loader initialization in your Gruntfile.js
:
grunt silent: false;
License
MIT