summaryrefslogtreecommitdiff
path: root/deps/npm/lib/utils
diff options
context:
space:
mode:
authorRebecca Turner <me@re-becca.org>2017-04-12 21:47:49 -0700
committerJeremiah Senkpiel <fishrock123@rocketmail.com>2017-04-25 10:52:01 -0400
commit00842604483e4c2e622dfdb3a97440e07646158f (patch)
treef3346902636a44b6037652523767636bf7e4f2c9 /deps/npm/lib/utils
parent061c5da010e0d249379618382a499840d38247b8 (diff)
downloadandroid-node-v8-00842604483e4c2e622dfdb3a97440e07646158f.tar.gz
android-node-v8-00842604483e4c2e622dfdb3a97440e07646158f.tar.bz2
android-node-v8-00842604483e4c2e622dfdb3a97440e07646158f.zip
deps: upgrade npm to 4.5.0
PR-URL: https://github.com/nodejs/node/pull/12480 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'deps/npm/lib/utils')
-rwxr-xr-xdeps/npm/lib/utils/completion.sh5
-rw-r--r--deps/npm/lib/utils/error-handler.js71
-rw-r--r--deps/npm/lib/utils/error-message.js9
-rw-r--r--deps/npm/lib/utils/lifecycle.js10
-rw-r--r--deps/npm/lib/utils/move.js19
-rw-r--r--deps/npm/lib/utils/rename.js21
-rw-r--r--deps/npm/lib/utils/tar.js4
7 files changed, 76 insertions, 63 deletions
diff --git a/deps/npm/lib/utils/completion.sh b/deps/npm/lib/utils/completion.sh
index 25bef2c17b..c549b31c96 100755
--- a/deps/npm/lib/utils/completion.sh
+++ b/deps/npm/lib/utils/completion.sh
@@ -11,7 +11,7 @@ if type complete &>/dev/null; then
_npm_completion () {
local words cword
if type _get_comp_words_by_ref &>/dev/null; then
- _get_comp_words_by_ref -n = -n @ -w words -i cword
+ _get_comp_words_by_ref -n = -n @ -n : -w words -i cword
else
cword="$COMP_CWORD"
words=("${COMP_WORDS[@]}")
@@ -24,6 +24,9 @@ if type complete &>/dev/null; then
npm completion -- "${words[@]}" \
2>/dev/null)) || return $?
IFS="$si"
+ if type __ltrim_colon_completions &>/dev/null; then
+ __ltrim_colon_completions "${words[cword]}"
+ fi
}
complete -o default -F _npm_completion npm
elif type compdef &>/dev/null; then
diff --git a/deps/npm/lib/utils/error-handler.js b/deps/npm/lib/utils/error-handler.js
index a2911a101a..1213902886 100644
--- a/deps/npm/lib/utils/error-handler.js
+++ b/deps/npm/lib/utils/error-handler.js
@@ -4,17 +4,16 @@ module.exports = errorHandler
var cbCalled = false
var log = require('npmlog')
var npm = require('../npm.js')
-var rm = require('rimraf')
var itWorked = false
var path = require('path')
var wroteLogFile = false
var exitCode = 0
var rollbacks = npm.rollbacks
var chain = require('slide').chain
-var writeStreamAtomic = require('fs-write-stream-atomic')
+var writeFileAtomic = require('write-file-atomic')
var errorMessage = require('./error-message.js')
var stopMetrics = require('./metrics.js').stop
-var mkdir = require('mkdirp')
+var mkdirp = require('mkdirp')
var logFileName
function getLogFile () {
@@ -32,10 +31,15 @@ process.on('exit', function (code) {
stopMetrics()
if (code) itWorked = false
- if (itWorked) log.info('ok')
- else {
+ if (itWorked) {
+ log.info('ok')
+ } else {
if (!cbCalled) {
log.error('', 'cb() never called!')
+ console.error('')
+ log.error('', 'This is an error with npm itself. Please report this error at:')
+ log.error('', ' <https://github.com/npm/npm/issues>')
+ writeLogFile()
}
if (wroteLogFile) {
@@ -45,7 +49,7 @@ process.on('exit', function (code) {
log.error(
'',
[
- 'Please include the following file with any support request:',
+ 'A complete log of this run can be found in:',
' ' + getLogFile()
].join('\n')
)
@@ -83,19 +87,22 @@ function exit (code, noLog) {
}), function (er) {
if (er) {
log.error('error rolling back', er)
- if (!code) errorHandler(er)
- else if (noLog) rm('npm-debug.log', reallyExit.bind(null, er))
- else writeLogFile(reallyExit.bind(this, er))
+ if (!code) {
+ errorHandler(er)
+ } else {
+ if (!noLog) writeLogFile()
+ reallyExit(er)
+ }
} else {
- if (!noLog && code) writeLogFile(reallyExit)
- else rm(getLogFile(), reallyExit)
+ if (!noLog && code) writeLogFile()
+ reallyExit()
}
})
rollbacks.length = 0
} else if (code && !noLog) {
writeLogFile(reallyExit)
} else {
- rm('npm-debug.log', reallyExit)
+ reallyExit()
}
function reallyExit (er) {
@@ -115,7 +122,6 @@ function exit (code, noLog) {
function errorHandler (er) {
log.disableProgress()
- // console.error('errorHandler', er)
if (!npm.config || !npm.config.loaded) {
// logging won't work unless we pretend that it's ready
er = er || new Error('Exit prior to config file resolving.')
@@ -163,14 +169,10 @@ function errorHandler (er) {
log.verbose('cwd', process.cwd())
var os = require('os')
- // log.error('System', os.type() + ' ' + os.release())
- // log.error('command', process.argv.map(JSON.stringify).join(' '))
- // log.error('node -v', process.version)
- // log.error('npm -v', npm.version)
- log.error('', os.type() + ' ' + os.release())
- log.error('argv', process.argv.map(JSON.stringify).join(' '))
- log.error('node', process.version)
- log.error('npm ', 'v' + npm.version)
+ log.verbose('', os.type() + ' ' + os.release())
+ log.verbose('argv', process.argv.map(JSON.stringify).join(' '))
+ log.verbose('node', process.version)
+ log.verbose('npm ', 'v' + npm.version)
;[
'file',
@@ -183,9 +185,6 @@ function errorHandler (er) {
if (v) log.error(k, v)
})
- // just a line break
- if (log.levels[log.level] <= log.levels.error) console.error('')
-
var msg = errorMessage(er)
msg.summary.concat(msg.detail).forEach(function (errline) {
log.error.apply(log, errline)
@@ -194,20 +193,15 @@ function errorHandler (er) {
exit(typeof er.errno === 'number' ? er.errno : 1)
}
-var writingLogFile = false
-function writeLogFile (cb) {
- if (writingLogFile) return cb()
- writingLogFile = true
+function writeLogFile () {
+ if (wroteLogFile) return
wroteLogFile = true
var os = require('os')
- mkdir(path.resolve(npm.config.get('cache'), '_logs'), function (er) {
- if (er) {
- cb(er)
- return
- }
- var fstr = writeStreamAtomic(getLogFile())
+ try {
+ mkdirp.sync(path.resolve(npm.config.get('cache'), '_logs'))
+ var logOutput = ''
log.record.forEach(function (m) {
var pref = [m.id, m.level]
if (m.prefix) pref.push(m.prefix)
@@ -216,10 +210,11 @@ function writeLogFile (cb) {
m.message.trim().split(/\r?\n/).map(function (line) {
return (pref + ' ' + line).trim()
}).forEach(function (line) {
- fstr.write(line + os.EOL)
+ logOutput += line + os.EOL
})
})
- fstr.end()
- fstr.on('close', cb)
- })
+ writeFileAtomic.sync(getLogFile(), logOutput)
+ } catch (ex) {
+ return
+ }
}
diff --git a/deps/npm/lib/utils/error-message.js b/deps/npm/lib/utils/error-message.js
index 5c7ce15bf1..f19d0bf6d3 100644
--- a/deps/npm/lib/utils/error-message.js
+++ b/deps/npm/lib/utils/error-message.js
@@ -268,7 +268,6 @@ function errorMessage (er) {
detail.push([
'enoent',
[
- er.message,
'This is most likely not a problem with npm itself',
'and is related to npm not being able to find a file.',
er.file ? "\nCheck if the file '" + er.file + "' is present." : ''
@@ -304,14 +303,6 @@ function errorMessage (er) {
default:
short.push(['', er.message || er])
- detail.push([
- '',
- [
- '',
- 'If you need help, you may report this error at:',
- ' <https://github.com/npm/npm/issues>'
- ].join('\n')
- ])
break
}
if (er.optional) {
diff --git a/deps/npm/lib/utils/lifecycle.js b/deps/npm/lib/utils/lifecycle.js
index f48d5e2a3b..4ab5e0979a 100644
--- a/deps/npm/lib/utils/lifecycle.js
+++ b/deps/npm/lib/utils/lifecycle.js
@@ -282,6 +282,7 @@ function runCmd_ (cmd, pkg, env, wd, stage, unsafe, uid, gid, cb_) {
procError(er)
})
process.once('SIGTERM', procKill)
+ process.once('SIGINT', procInterupt)
function procError (er) {
if (er) {
@@ -302,11 +303,20 @@ function runCmd_ (cmd, pkg, env, wd, stage, unsafe, uid, gid, cb_) {
er.pkgname = pkg.name
}
process.removeListener('SIGTERM', procKill)
+ process.removeListener('SIGTERM', procInterupt)
+ process.removeListener('SIGINT', procKill)
return cb(er)
}
function procKill () {
proc.kill()
}
+ function procInterupt () {
+ proc.kill('SIGINT')
+ proc.on('exit', function () {
+ process.exit()
+ })
+ process.once('SIGINT', procKill)
+ }
}
function runHookLifecycle (pkg, env, wd, unsafe, cb) {
diff --git a/deps/npm/lib/utils/move.js b/deps/npm/lib/utils/move.js
new file mode 100644
index 0000000000..242e87d37f
--- /dev/null
+++ b/deps/npm/lib/utils/move.js
@@ -0,0 +1,19 @@
+'use strict'
+module.exports = wrappedMove
+
+var fs = require('graceful-fs')
+var move = require('move-concurrently')
+var Bluebird = require('bluebird')
+
+function wrappedMove (from, to, cb) {
+ var movePromise = move(from, to, {fs: fs, Promise: Bluebird, maxConcurrency: 4})
+ if (cb) {
+ return movePromise.then(function (value) {
+ cb(value)
+ }, function (err) {
+ cb(err)
+ })
+ } else {
+ return movePromise
+ }
+}
diff --git a/deps/npm/lib/utils/rename.js b/deps/npm/lib/utils/rename.js
index 8a44428984..43a2f7e104 100644
--- a/deps/npm/lib/utils/rename.js
+++ b/deps/npm/lib/utils/rename.js
@@ -1,16 +1,9 @@
-'use strict'
-var fs = require('graceful-fs')
-var SaveStack = require('./save-stack.js')
+/*
-module.exports = rename
+This is a stub file to ensure that the following hack doesn't break. This can be removed w/ npm@5.
-function rename (from, to, cb) {
- var saved = new SaveStack(rename)
- fs.rename(from, to, function (er) {
- if (er) {
- return cb(saved.completeWith(er))
- } else {
- return cb()
- }
- })
-}
+# Fix bug https://github.com/npm/npm/issues/9863
+RUN cd $(npm root -g)/npm \
+ && npm install fs-extra \
+ && sed -i -e s/graceful-fs/fs-extra/ -e s/fs\.rename/fs.move/ ./lib/utils/rename.js
+*/
diff --git a/deps/npm/lib/utils/tar.js b/deps/npm/lib/utils/tar.js
index f580c8e05d..88cfc6b805 100644
--- a/deps/npm/lib/utils/tar.js
+++ b/deps/npm/lib/utils/tar.js
@@ -136,8 +136,10 @@ BundledPacker.prototype.applyIgnores = function (entry, partial, entryObj) {
// the package root.
var p = this.parent
- // the package before this one.
+ // the directory before this one.
var pp = p && p.parent
+ // the directory before that (if this is scoped)
+ if (pp && pp.basename[0] === '@') pp = pp && pp.parent
// if this entry has already been bundled, and is a symlink,
// and it is the *same* symlink as this one, then exclude it.