Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow optional passing of command args to npm install and prune #84

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ Default value: `'npm'`

The location of the `npm` executable. Defaults to `'npm'` as it should be available in the `$PATH` environment variable.

#### options.npmInstallArgs
Type: `array`
Default value: `['install']`

The command and arguments to pass to `npm install` operations. For example in CI environments you can use `['ci']` and we'd run `npm ci` for install operations instead.

#### options.npmCleanArgs
Type: `array`
Default value: `['prune', '--production']`

The command and arguments to pass to `npm prune` operations. For example in CI environments you can use `['ci']` and we'd run `npm ci` for install operations instead.

#### options.passGruntFlags
Type: `bool`
Default value: `true`
Expand Down
6 changes: 4 additions & 2 deletions tasks/subgrunt.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = function (grunt) {
const runNpmInstall = function (path, options, next) {
grunt.util.spawn({
cmd: options.npmPath,
args: ['install'],
args: options.npmInstallArgs,
opts: {cwd: path, stdio: 'inherit'}
}, (err, result, code) => {
if (err || code > 0) {
Expand All @@ -25,7 +25,7 @@ module.exports = function (grunt) {

grunt.util.spawn({
cmd: options.npmPath,
args: ['prune', '--production'],
args: options.npmCleanArgs,
opts: {cwd: path, stdio: 'inherit'}
}, (err, result, code) => {
if (err || code > 0) {
Expand Down Expand Up @@ -71,6 +71,8 @@ module.exports = function (grunt) {
npmInstall: true,
npmClean: false,
npmPath: 'npm',
npmInstallArgs: ['install'],
npmCleanArgs: ['prune', '--production'],
passGruntFlags: true,
limit: Math.max(require('os').cpus().length, 2)
})
Expand Down