Skip to content

Commit

Permalink
git-prepare: Fix child process npm run
Browse files Browse the repository at this point in the history
Previously it used the global npm, not the npm we were running from.
  • Loading branch information
iarna committed May 26, 2017
1 parent ebbe7a0 commit 3c34282
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
19 changes: 14 additions & 5 deletions lib/config/pacote.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,13 @@ function prepareAndPack (manifest, dir) {
})
let errData = []
let errDataLen = 0
child.stdout.on('data', () => log.gauge.pulse('preparing git package'))
let outData = []
let outDataLen = 0
child.stdout.on('data', (data) => {
outData.push(data)
outDataLen += data.length
log.gauge.pulse('preparing git package'))
})
child.stderr.on('data', (data) => {
errData.push(data)
errDataLen += data.length
Expand All @@ -144,10 +150,6 @@ function prepareAndPack (manifest, dir) {
child.on('error', cb)
child.on('exit', (code, signal) => {
if (code > 0) {
log.error(
'prepare-git-dep',
Buffer.concat(errData, errDataLen).toString('utf8')
)
const err = new Error(`${signal}: npm exited with code ${code} while attempting to build ${manifest._requested}. Clone the repository manually and run 'npm install' in it for more information.`)
err.code = code
err.signal = signal
Expand All @@ -156,6 +158,13 @@ function prepareAndPack (manifest, dir) {
cb()
}
})
}).then(() => {
if (outDataLen > 0) log.silly('prepareGitDep', '1>', Buffer.concat(outData, outDataLen).toString())
if (errDataLen > 0) log.silly('prepareGitDep', '2>', Buffer.concat(errData, errDataLen).toString())
}, (err) => {
if (outDataLen > 0) log.error('prepareGitDep', '1>', Buffer.concat(outData, outDataLen).toString())
if (errDataLen > 0) log.error('prepareGitDep', '2>', Buffer.concat(errData, errDataLen).toString())
throw err
})
}
}).then(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ test('install from git repo with prepare script', function (t) {

common.npm([
'install',
'--no-save',
'--registry', common.registry,
'--cache', cache,
'--loglevel', 'error'
Expand Down

0 comments on commit 3c34282

Please sign in to comment.