summaryrefslogtreecommitdiff
path: root/deps/npm/lib/install/action
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/lib/install/action')
-rw-r--r--deps/npm/lib/install/action/build.js2
-rw-r--r--deps/npm/lib/install/action/extract.js3
-rw-r--r--deps/npm/lib/install/action/fetch.js6
-rw-r--r--deps/npm/lib/install/action/finalize.js21
-rw-r--r--deps/npm/lib/install/action/refresh-package-json.js2
5 files changed, 25 insertions, 9 deletions
diff --git a/deps/npm/lib/install/action/build.js b/deps/npm/lib/install/action/build.js
index f59b852e84..be2c141f0d 100644
--- a/deps/npm/lib/install/action/build.js
+++ b/deps/npm/lib/install/action/build.js
@@ -7,7 +7,7 @@ var packageId = require('../../utils/package-id.js')
module.exports = function (staging, pkg, log, next) {
log.silly('build', packageId(pkg))
chain([
- [build.linkStuff, pkg.package, pkg.path, npm.config.get('global'), true],
+ [build.linkStuff, pkg.package, pkg.path, npm.config.get('global')],
[build.writeBuiltinConf, pkg.package, pkg.path]
], next)
}
diff --git a/deps/npm/lib/install/action/extract.js b/deps/npm/lib/install/action/extract.js
index 8e80d4adda..6b827f36ea 100644
--- a/deps/npm/lib/install/action/extract.js
+++ b/deps/npm/lib/install/action/extract.js
@@ -16,6 +16,7 @@ let pacoteOpts
const path = require('path')
const localWorker = require('./extract-worker.js')
const workerFarm = require('worker-farm')
+const isRegistry = require('../../utils/is-registry.js')
const WORKER_PATH = require.resolve('./extract-worker.js')
let workers
@@ -72,7 +73,7 @@ function extract (staging, pkg, log) {
let msg = args
const spec = typeof args[0] === 'string' ? npa(args[0]) : args[0]
args[0] = spec.raw
- if (ENABLE_WORKERS && (spec.registry || spec.type === 'remote')) {
+ if (ENABLE_WORKERS && (isRegistry(spec) || spec.type === 'remote')) {
// We can't serialize these options
opts.loglevel = opts.log.level
opts.log = null
diff --git a/deps/npm/lib/install/action/fetch.js b/deps/npm/lib/install/action/fetch.js
index 474e00b05c..a4d760fe82 100644
--- a/deps/npm/lib/install/action/fetch.js
+++ b/deps/npm/lib/install/action/fetch.js
@@ -1,5 +1,8 @@
'use strict'
+const BB = require('bluebird')
+
+const finished = BB.promisify(require('mississippi').finished)
const packageId = require('../../utils/package-id.js')
const pacote = require('pacote')
const pacoteOpts = require('../../config/pacote')
@@ -8,5 +11,6 @@ module.exports = fetch
function fetch (staging, pkg, log, next) {
log.silly('fetch', packageId(pkg))
const opts = pacoteOpts({integrity: pkg.package._integrity})
- pacote.prefetch(pkg.package._requested, opts).then(() => next(), next)
+ return finished(pacote.tarball.stream(pkg.package._requested, opts))
+ .then(() => next(), next)
}
diff --git a/deps/npm/lib/install/action/finalize.js b/deps/npm/lib/install/action/finalize.js
index a50ec8a6bd..e46f1b9d83 100644
--- a/deps/npm/lib/install/action/finalize.js
+++ b/deps/npm/lib/install/action/finalize.js
@@ -7,11 +7,13 @@ const mkdirp = Bluebird.promisify(require('mkdirp'))
const lstat = Bluebird.promisify(fs.lstat)
const readdir = Bluebird.promisify(fs.readdir)
const symlink = Bluebird.promisify(fs.symlink)
-const gentlyRm = require('../../utils/gently-rm')
+const gentlyRm = Bluebird.promisify(require('../../utils/gently-rm'))
const moduleStagingPath = require('../module-staging-path.js')
const move = require('move-concurrently')
const moveOpts = {fs: fs, Promise: Bluebird, maxConcurrency: 4}
const getRequested = require('../get-requested.js')
+const log = require('npmlog')
+const packageId = require('../../utils/package-id.js')
module.exports = function (staging, pkg, log) {
log.silly('finalize', pkg.realpath)
@@ -88,8 +90,17 @@ module.exports = function (staging, pkg, log) {
}
}
-module.exports.rollback = function (top, staging, pkg, next) {
- const requested = pkg.package._requested || getRequested(pkg)
- if (requested && requested.type === 'directory') return next()
- gentlyRm(pkg.path, false, top, next)
+module.exports.rollback = function (top, staging, pkg) {
+ return Bluebird.try(() => {
+ const requested = pkg.package._requested || getRequested(pkg)
+ if (requested && requested.type === 'directory') return Promise.resolve()
+ // strictly speaking rolling back a finalize should ONLY remove module that
+ // was being finalized, not any of the things under it. But currently
+ // those modules are guaranteed to be useless so we may as well remove them too.
+ // When/if we separate `commit` step and can rollback to previous versions
+ // of upgraded modules then we'll need to revisit this…
+ return gentlyRm(pkg.path, false, top).catch((err) => {
+ log.warn('rollback', `Rolling back ${packageId(pkg)} failed (this is probably harmless): ${err.message ? err.message : err}`)
+ })
+ })
}
diff --git a/deps/npm/lib/install/action/refresh-package-json.js b/deps/npm/lib/install/action/refresh-package-json.js
index 42f8012100..32e6444444 100644
--- a/deps/npm/lib/install/action/refresh-package-json.js
+++ b/deps/npm/lib/install/action/refresh-package-json.js
@@ -14,7 +14,7 @@ module.exports = function (staging, pkg, log) {
return readJson(path.join(pkg.path, 'package.json'), false).then((metadata) => {
Object.keys(pkg.package).forEach(function (key) {
- if (key !== 'dependencies' && !isEmpty(pkg.package[key])) {
+ if (key !== 'version' && key !== 'dependencies' && !isEmpty(pkg.package[key])) {
metadata[key] = pkg.package[key]
}
})