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:
authorKat Marchán <kzm@sykosomatic.org>2017-05-12 08:02:02 +0300
committerRebecca Turner <me@re-becca.org>2017-05-26 04:55:18 +0300
commit8cfd94ac132f2c2b3f1e0f085291b89b4cfcf526 (patch)
tree1fee84bfa5a799aca92c76edfdaec86809326b1a /lib
parent3d629fb91cb82b74b15c4e7bdafa826c399d99af (diff)
fix(shrinkwrap): promisify to fix dropped errors
Diffstat (limited to 'lib')
-rw-r--r--lib/shrinkwrap.js46
1 files changed, 23 insertions, 23 deletions
diff --git a/lib/shrinkwrap.js b/lib/shrinkwrap.js
index 531ea75c8..832479e73 100644
--- a/lib/shrinkwrap.js
+++ b/lib/shrinkwrap.js
@@ -4,12 +4,14 @@ const BB = require('bluebird')
const chain = require('slide').chain
const detectIndent = require('detect-indent')
+const fs = BB.promisifyAll(require('graceful-fs'))
+const getRequested = require('./install/get-requested.js')
+const id = require('./install/deps.js')
const iferr = require('iferr')
const isDevDep = require('./install/is-dev-dep.js')
const isExtraneous = require('./install/is-extraneous.js')
const isOptDep = require('./install/is-opt-dep.js')
const isProdDep = require('./install/is-prod-dep.js')
-const fs = BB.promisifyAll(require('graceful-fs'))
const lifecycle = require('./utils/lifecycle.js')
const log = require('npmlog')
const moduleName = require('./utils/module-name.js')
@@ -17,14 +19,13 @@ const move = require('move-concurrently')
const npm = require('./npm.js')
const packageId = require('./utils/package-id.js')
const path = require('path')
-const readPackageTree = require('read-package-tree')
+const readPackageTree = BB.promisify(require('read-package-tree'))
const ssri = require('ssri')
const validate = require('aproba')
-const id = require('./install/deps.js')
const writeFileAtomic = require('write-file-atomic')
-const SHRINKWRAP = 'npm-shrinkwrap.json'
+
const PKGLOCK = 'package-lock.json'
-const getRequested = require('./install/get-requested.js')
+const SHRINKWRAP = 'npm-shrinkwrap.json'
// emit JSON describing versions of all packages currently installed (for later
// use with shrinkwrap install)
@@ -49,15 +50,23 @@ function shrinkwrap (args, silent, cb) {
log.notice('', `${PKGLOCK} has been renamed to ${SHRINKWRAP}. ${SHRINKWRAP} will be used for future installations.`)
return fs.readFileAsync(path.resolve(npm.prefix, SHRINKWRAP)).then((d) => {
return JSON.parse(d)
- }).then((sw) => cb(null, sw), cb)
- }).catch({code: 'ENOENT'}, () => {
- readPackageTree(npm.localPrefix, andComputeMetadata(iferr(cb, function (tree) {
- createShrinkwrap(tree, {
- silent,
- defaultFile: SHRINKWRAP
- }, cb)
- })))
- })
+ })
+ }, (err) => {
+ if (err.code !== 'ENOENT') {
+ throw err
+ } else {
+ return readPackageTree(npm.localPrefix).then(
+ id.computeMetadata
+ ).then((tree) => {
+ return BB.fromNode((cb) => {
+ createShrinkwrap(tree, {
+ silent,
+ defaultFile: SHRINKWRAP
+ }, cb)
+ })
+ })
+ }
+ }).then((data) => cb(null, data), cb)
}
module.exports.createShrinkwrap = createShrinkwrap
@@ -77,15 +86,6 @@ function createShrinkwrap (tree, opts, cb) {
})
}
-function andComputeMetadata (next) {
- validate('F', arguments)
- return function (er, tree) {
- validate('EO', arguments)
- if (er) return next(er)
- next(null, id.computeMetadata(tree))
- }
-}
-
function treeToShrinkwrap (tree) {
validate('O', arguments)
var pkginfo = {}