Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormmkal <misha.kaletsky@gmail.com>2017-07-04 07:25:35 +0300
committerKat Marchán <kzm@sykosomatic.org>2017-07-06 01:11:03 +0300
commita09c1a69df05b753464cc1272cdccc6af0f4da5a (patch)
treeb2580662d7b90dfc52eac7514d3d3a4e74ef5321 /lib
parent7d650048c8ed5faa0486492f1eeb698e7383e32f (diff)
run-script: allow custom shell (#16687)
Fixes: https://github.com/npm/npm/issues/6543 PR-URL: https://github.com/npm/npm/pull/16687 Credit: @mmkal Reviewed-By: @zkat Reviewed-By: @iarna
Diffstat (limited to 'lib')
-rw-r--r--lib/config/defaults.js2
-rw-r--r--lib/utils/lifecycle.js6
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/config/defaults.js b/lib/config/defaults.js
index da019ac4d..93bac84a6 100644
--- a/lib/config/defaults.js
+++ b/lib/config/defaults.js
@@ -203,6 +203,7 @@ Object.defineProperty(exports, 'defaults', {get: function () {
'save-prefix': '^',
'save-prod': false,
scope: '',
+ 'script-shell': null,
'scripts-prepend-node-path': 'warn-only',
searchopts: '',
searchexclude: null,
@@ -326,6 +327,7 @@ exports.types = {
'save-prefix': String,
'save-prod': Boolean,
scope: String,
+ 'script-shell': [null, String],
'scripts-prepend-node-path': [false, true, 'auto', 'warn-only'],
searchopts: String,
searchexclude: [null, String],
diff --git a/lib/utils/lifecycle.js b/lib/utils/lifecycle.js
index 02ba485ae..412c1c694 100644
--- a/lib/utils/lifecycle.js
+++ b/lib/utils/lifecycle.js
@@ -264,7 +264,11 @@ function runCmd_ (cmd, pkg, env, wd, stage, unsafe, uid, gid, cb_) {
var sh = 'sh'
var shFlag = '-c'
- if (process.platform === 'win32') {
+ var customShell = npm.config.get('script-shell')
+
+ if (customShell) {
+ sh = customShell
+ } else if (process.platform === 'win32') {
sh = process.env.comspec || 'cmd'
shFlag = '/d /s /c'
conf.windowsVerbatimArguments = true