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
diff options
context:
space:
mode:
-rw-r--r--lib/install/logical-tree.js6
-rw-r--r--lib/ls.js34
2 files changed, 24 insertions, 16 deletions
diff --git a/lib/install/logical-tree.js b/lib/install/logical-tree.js
index 8a3da74df..f0faf6e78 100644
--- a/lib/install/logical-tree.js
+++ b/lib/install/logical-tree.js
@@ -68,7 +68,11 @@ function translateTree (tree) {
pkg.dependencies[name].realName = name
pkg.dependencies[name].extraneous = false
} else {
- pkg.dependencies[name] = tree.missingDeps[name]
+ pkg.dependencies[name] = {
+ requiredBy: tree.missingDeps[name],
+ missing: true,
+ optional: !!pkg.optionalDependencies[name]
+ }
}
})
if (tree.missingPeers) {
diff --git a/lib/ls.js b/lib/ls.js
index 35885ad8c..5bc3c963b 100644
--- a/lib/ls.js
+++ b/lib/ls.js
@@ -120,7 +120,7 @@ function filterByEnv (data) {
var keys = Object.keys(devDependencies)
if (production && !dev && keys.indexOf(name) !== -1) return
if (dev && !production && keys.indexOf(name) === -1) return
- if (!dev && keys.indexOf(name) !== -1 && typeof data.dependencies[name] === 'string') return
+ if (!dev && keys.indexOf(name) !== -1 && data.dependencies[name].missing) return
dependencies[name] = data.dependencies[name]
})
data.dependencies = dependencies
@@ -175,7 +175,7 @@ function getLite (data, noname) {
if (deps.length) {
lite.dependencies = deps.map(function (d) {
var dep = data.dependencies[d]
- if (typeof dep === 'string') {
+ if (dep.missing && !dep.optional) {
lite.problems = lite.problems || []
var p
if (data.depth > maxDepth) {
@@ -183,11 +183,11 @@ function getLite (data, noname) {
} else {
p = 'missing: '
}
- p += d + '@' + dep +
+ p += d + '@' + dep.requiredBy +
', required by ' +
data.name + '@' + data.version
lite.problems.push(p)
- return [d, { required: dep, missing: true }]
+ return [d, { required: dep.requiredBy, missing: true }]
} else if (dep.peerMissing) {
lite.problems = lite.problems || []
var p = 'peer dep missing: ' +
@@ -228,7 +228,7 @@ function bfsify (root) {
var deps = current.dependencies = current.dependencies || {}
Object.keys(deps).forEach(function (d) {
var dep = deps[d]
- if (typeof dep !== 'object') return
+ if (dep.missing) return
if (seen.indexOf(dep) !== -1) {
if (npm.config.get('parseable') || !npm.config.get('long')) {
delete deps[d]
@@ -279,16 +279,20 @@ function makeArchy (data, long, dir) {
}
function makeArchy_ (data, long, dir, depth, parent, d) {
- if (typeof data === 'string') {
+ if (data.missing) {
if (depth - 1 <= npm.config.get('depth')) {
// just missing
- var unmet = 'UNMET DEPENDENCY'
+ var unmet = 'UNMET ' + (data.optional ? 'OPTIONAL ' : '') + 'DEPENDENCY'
if (npm.color) {
- unmet = color.bgBlack(color.red(unmet))
+ if (data.optional) {
+ unmet = color.bgBlack(color.yellow(unmet))
+ } else {
+ unmet = color.bgBlack(color.red(unmet))
+ }
}
- data = unmet + ' ' + d + '@' + data
+ data = unmet + ' ' + d + '@' + data.requiredBy
} else {
- data = d + '@' + data
+ data = d + '@' + data.requiredBy
}
return data
}
@@ -399,16 +403,16 @@ function makeParseable (data, long, dir, depth, parent, d) {
function makeParseable_ (data, long, dir, depth, parent, d) {
if (data.hasOwnProperty('_found') && data._found !== true) return ''
- if (typeof data === 'string') {
- if (data.depth < npm.config.get('depth')) {
+ if (data.missing) {
+ if (depth < npm.config.get('depth')) {
data = npm.config.get('long')
? path.resolve(parent.path, 'node_modules', d) +
- ':' + d + '@' + JSON.stringify(data) + ':INVALID:MISSING'
+ ':' + d + '@' + JSON.stringify(data.requiredBy) + ':INVALID:MISSING'
: ''
} else {
- data = path.resolve(data.path || '', 'node_modules', d || '') +
+ data = path.resolve(dir || '', 'node_modules', d || '') +
(npm.config.get('long')
- ? ':' + d + '@' + JSON.stringify(data) +
+ ? ':' + d + '@' + JSON.stringify(data.requiredBy) +
':' + // no realpath resolved
':MAXDEPTH'
: '')