Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: npm/npm-lifecycle
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.0.0
Choose a base ref
...
head repository: npm/npm-lifecycle
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.1.0
Choose a head ref
  • 8 commits
  • 7 files changed
  • 5 contributors

Commits on Jul 17, 2019

  1. update deps

    isaacs committed Jul 17, 2019

    Unverified

    This user has not yet uploaded their public signing key.
    Copy the full SHA
    ab15975 View commit details
  2. fix: remove procInterrupt listener on SIGINT in procError

    PR-URL: #36
    Close: #36
    Reviewed-by: @isaacs
    Credit: @mattshin
    Fix: #11
    Fix: #18
    Matthew Shin authored and isaacs committed Jul 17, 2019
    Copy the full SHA
    ea18ed2 View commit details
  3. feat(process.env.path): Use platform specific path casing if present

    Assume proper win32 path casing - only seek out alternative casing if
    win32 OS specific casing not present.
    
    Fix: #29
    PR-URL: #30
    Close: #30
    Reviewed-by: @isaacs
    mattezell authored and isaacs committed Jul 17, 2019
    Copy the full SHA
    5523951 View commit details
  4. Copy the full SHA
    d391b04 View commit details
  5. fix: set only one PATH env variable for child proc

    without the revert and a new version of pnpm with rever #22.
    
    Old npm was duplicating the PATH env variables.
    New pnpm was not overriding all of them.
    
    Using only one PATH env variable will reduce uncertainty.
    
    PR-URL: #25
    Close: #25
    Reviewed-by: @isaacs
    Credit: @zkochan
    zkochan authored and isaacs committed Jul 17, 2019
    Copy the full SHA
    3aaf954 View commit details
  6. fix switches for alternative shells on Windows

    On Windows, normalizeSpawnArguments set "/d /s /c" for any shells.
    It cause exec and other methods are limited to cmd.exe as a shell.
    
    Powershell and git-bash are often used instead of cmd.exe,
    and they can recieve "-c" switch like unix shells.
    So normalizeSpawnArguments is changed to set "/d /s /c" for cmd.exe,
    and "-c" for others.
    
    PR-URL: #26
    Close: #26
    Reviewed-by: @isaacs
    Credit: @gucong3000
    gucong3000 authored and isaacs committed Jul 17, 2019
    Copy the full SHA
    051cf20 View commit details
  7. Copy the full SHA
    9986486 View commit details
  8. chore(release): 3.1.0

    isaacs committed Jul 17, 2019
    Copy the full SHA
    d97ded5 View commit details
Showing with 1,741 additions and 1,674 deletions.
  1. +16 −0 CHANGELOG.md
  2. +45 −28 index.js
  3. +1,508 −1,645 package-lock.json
  4. +1 −1 package.json
  5. +89 −0 tap-snapshots/test-get-spawn-args.js-TAP.test.js
  6. +43 −0 test/get-spawn-args.js
  7. +39 −0 test/win32-set-path.js
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,22 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

<a name="3.1.0"></a>
# [3.1.0](https://github.com/npm/lifecycle/compare/v3.0.0...v3.1.0) (2019-07-17)


### Bug Fixes

* remove procInterrupt listener on SIGINT in procError ([ea18ed2](https://github.com/npm/lifecycle/commit/ea18ed2)), closes [#36](https://github.com/npm/lifecycle/issues/36) [#11](https://github.com/npm/lifecycle/issues/11) [#18](https://github.com/npm/lifecycle/issues/18)
* set only one PATH env variable for child proc ([3aaf954](https://github.com/npm/lifecycle/commit/3aaf954)), closes [#22](https://github.com/npm/lifecycle/issues/22) [#25](https://github.com/npm/lifecycle/issues/25)


### Features

* **process.env.path:** Use platform specific path casing if present ([5523951](https://github.com/npm/lifecycle/commit/5523951)), closes [#29](https://github.com/npm/lifecycle/issues/29) [#30](https://github.com/npm/lifecycle/issues/30)



<a name="3.0.0"></a>
# [3.0.0](https://github.com/npm/lifecycle/compare/v2.1.1...v3.0.0) (2019-07-10)

73 changes: 45 additions & 28 deletions index.js
Original file line number Diff line number Diff line change
@@ -4,6 +4,9 @@ exports = module.exports = lifecycle
exports.makeEnv = makeEnv
exports._incorrectWorkingDirectory = _incorrectWorkingDirectory

// for testing
const platform = process.env.__TESTING_FAKE_PLATFORM__ || process.platform
const isWindows = platform === 'win32'
const spawn = require('./lib/spawn')
const path = require('path')
const Stream = require('stream').Stream
@@ -20,16 +23,20 @@ const hookStatCache = new Map()

let PATH = 'PATH'

// windows calls it's path 'Path' usually, but this is not guaranteed.
if (process.platform === 'win32') {
// windows calls its path 'Path' usually, but this is not guaranteed.
if (isWindows) {
PATH = 'Path'
Object.keys(process.env).forEach(function (e) {
if (e.match(/^PATH$/i)) {
PATH = e
}
})
if (!process.env[PATH]) {
Object.keys(process.env).forEach(function (e) {
if (e.match(/^PATH$/i)) {
PATH = e
}
})
}
}

exports._pathEnvName = PATH

function logid (pkg, stage) {
return pkg._id + '~' + stage + ':'
}
@@ -121,7 +128,7 @@ function lifecycle_ (pkg, stage, wd, opts, env, cb) {
}

if (env[PATH]) pathArr.push(env[PATH])
env[PATH] = pathArr.join(process.platform === 'win32' ? ';' : ':')
env[PATH] = pathArr.join(isWindows ? ';' : ':')

var packageLifecycle = pkg.scripts && pkg.scripts.hasOwnProperty(stage)

@@ -164,7 +171,6 @@ function shouldPrependCurrentNodeDirToPATH (opts) {

var isDifferentNodeInPath

var isWindows = process.platform === 'win32'
var foundExecPath
try {
foundExecPath = which.sync(path.basename(process.execPath), { pathExt: isWindows ? ';' : ':' })
@@ -242,7 +248,7 @@ function runCmd (note, cmd, pkg, env, stage, wd, opts, cb) {
}
opts.log.verbose('lifecycle', logid(pkg, stage), 'unsafe-perm in lifecycle', unsafe)

if (process.platform === 'win32') {
if (isWindows) {
unsafe = true
}

@@ -255,14 +261,8 @@ function runCmd (note, cmd, pkg, env, stage, wd, opts, cb) {
}
}

function runCmd_ (cmd, pkg, env, wd, opts, stage, unsafe, uid, gid, cb_) {
function cb (er) {
cb_.apply(null, arguments)
opts.log.resume()
process.nextTick(dequeue)
}

var conf = {
const getSpawnArgs = ({ cmd, wd, opts, uid, gid, unsafe, env }) => {
const conf = {
cwd: wd,
env: env,
stdio: opts.stdio || [ 0, 1, 2 ]
@@ -273,24 +273,40 @@ function runCmd_ (cmd, pkg, env, wd, opts, stage, unsafe, uid, gid, cb_) {
conf.gid = gid ^ 0
}

var sh = 'sh'
var shFlag = '-c'

var customShell = opts.scriptShell
const customShell = opts.scriptShell

let sh = 'sh'
let shFlag = '-c'
if (customShell) {
sh = customShell
} else if (process.platform === 'win32') {
} else if (isWindows || opts._TESTING_FAKE_WINDOWS_) {
sh = process.env.comspec || 'cmd'
shFlag = '/d /s /c'
conf.windowsVerbatimArguments = true
// '/d /s /c' is used only for cmd.exe.
if (/^(?:.*\\)?cmd(?:\.exe)?$/i.test(sh)) {
shFlag = '/d /s /c'
conf.windowsVerbatimArguments = true
}
}

return [sh, [shFlag, cmd], conf]
}

exports._getSpawnArgs = getSpawnArgs

function runCmd_ (cmd, pkg, env, wd, opts, stage, unsafe, uid, gid, cb_) {
function cb (er) {
cb_.apply(null, arguments)
opts.log.resume()
process.nextTick(dequeue)
}

const [sh, args, conf] = getSpawnArgs({ cmd, wd, opts, uid, gid, unsafe, env })

opts.log.verbose('lifecycle', logid(pkg, stage), 'PATH:', env[PATH])
opts.log.verbose('lifecycle', logid(pkg, stage), 'CWD:', wd)
opts.log.silly('lifecycle', logid(pkg, stage), 'Args:', [shFlag, cmd])
opts.log.silly('lifecycle', logid(pkg, stage), 'Args:', args)

var proc = spawn(sh, [shFlag, cmd], conf, opts.log)
var proc = spawn(sh, args, conf, opts.log)

proc.on('error', procError)
proc.on('close', function (code, signal) {
@@ -333,6 +349,7 @@ function runCmd_ (cmd, pkg, env, wd, opts, stage, unsafe, uid, gid, cb_) {
process.removeListener('SIGTERM', procKill)
process.removeListener('SIGTERM', procInterupt)
process.removeListener('SIGINT', procKill)
process.removeListener('SIGINT', procInterupt)
return cb(er)
}
function procKill () {
@@ -362,7 +379,7 @@ function makeEnv (data, opts, prefix, env) {
if (!env) {
env = {}
for (var i in process.env) {
if (!i.match(/^npm_/)) {
if (!i.match(/^npm_/) && (!i.match(/^PATH$/i) || i === PATH)) {
env[i] = process.env[i]
}
}
Loading