Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/smanonr..../lib/node_mod.../npm/lib
File: ls.js
// show the installed versions of packages
[0] Fix | Delete
//
[1] Fix | Delete
// --parseable creates output like this:
[2] Fix | Delete
// <fullpath>:<name@ver>:<realpath>:<flags>
[3] Fix | Delete
// Flags are a :-separated list of zero or more indicators
[4] Fix | Delete
[5] Fix | Delete
module.exports = exports = ls
[6] Fix | Delete
[7] Fix | Delete
var path = require('path')
[8] Fix | Delete
var url = require('url')
[9] Fix | Delete
var readPackageTree = require('read-package-tree')
[10] Fix | Delete
var archy = require('archy')
[11] Fix | Delete
var semver = require('semver')
[12] Fix | Delete
var color = require('ansicolors')
[13] Fix | Delete
var moduleName = require('./utils/module-name.js')
[14] Fix | Delete
var npa = require('npm-package-arg')
[15] Fix | Delete
var sortedObject = require('sorted-object')
[16] Fix | Delete
var npm = require('./npm.js')
[17] Fix | Delete
var mutateIntoLogicalTree = require('./install/mutate-into-logical-tree.js')
[18] Fix | Delete
var computeMetadata = require('./install/deps.js').computeMetadata
[19] Fix | Delete
var readShrinkwrap = require('./install/read-shrinkwrap.js')
[20] Fix | Delete
var packageId = require('./utils/package-id.js')
[21] Fix | Delete
var usage = require('./utils/usage')
[22] Fix | Delete
var output = require('./utils/output.js')
[23] Fix | Delete
[24] Fix | Delete
ls.usage = usage(
[25] Fix | Delete
'ls',
[26] Fix | Delete
'npm ls [[<@scope>/]<pkg> ...]'
[27] Fix | Delete
)
[28] Fix | Delete
[29] Fix | Delete
ls.completion = require('./utils/completion/installed-deep.js')
[30] Fix | Delete
[31] Fix | Delete
function ls (args, silent, cb) {
[32] Fix | Delete
if (typeof cb !== 'function') {
[33] Fix | Delete
cb = silent
[34] Fix | Delete
silent = false
[35] Fix | Delete
}
[36] Fix | Delete
var dir = path.resolve(npm.dir, '..')
[37] Fix | Delete
readPackageTree(dir, function (_, physicalTree) {
[38] Fix | Delete
if (!physicalTree) physicalTree = {package: {}, path: dir}
[39] Fix | Delete
physicalTree.isTop = true
[40] Fix | Delete
readShrinkwrap.andInflate(physicalTree, function () {
[41] Fix | Delete
lsFromTree(dir, computeMetadata(physicalTree), args, silent, cb)
[42] Fix | Delete
})
[43] Fix | Delete
})
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
function inList (list, value) {
[47] Fix | Delete
return list.indexOf(value) !== -1
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
var lsFromTree = ls.fromTree = function (dir, physicalTree, args, silent, cb) {
[51] Fix | Delete
if (typeof cb !== 'function') {
[52] Fix | Delete
cb = silent
[53] Fix | Delete
silent = false
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
// npm ls 'foo@~1.3' bar 'baz@<2'
[57] Fix | Delete
if (!args) {
[58] Fix | Delete
args = []
[59] Fix | Delete
} else {
[60] Fix | Delete
args = args.map(function (a) {
[61] Fix | Delete
if (typeof a === 'object' && a.package._requested.type === 'alias') {
[62] Fix | Delete
return [moduleName(a), `npm:${a.package.name}@${a.package.version}`, a]
[63] Fix | Delete
} else if (typeof a === 'object') {
[64] Fix | Delete
return [a.package.name, a.package.version, a]
[65] Fix | Delete
} else {
[66] Fix | Delete
var p = npa(a)
[67] Fix | Delete
var name = p.name
[68] Fix | Delete
// When version spec is missing, we'll skip using it when filtering.
[69] Fix | Delete
// Otherwise, `semver.validRange` would return '*', which won't
[70] Fix | Delete
// match prerelease versions.
[71] Fix | Delete
var ver = (p.rawSpec &&
[72] Fix | Delete
(semver.validRange(p.rawSpec) || ''))
[73] Fix | Delete
return [ name, ver, a ]
[74] Fix | Delete
}
[75] Fix | Delete
})
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
var data = mutateIntoLogicalTree.asReadInstalled(physicalTree)
[79] Fix | Delete
[80] Fix | Delete
pruneNestedExtraneous(data)
[81] Fix | Delete
filterByEnv(data)
[82] Fix | Delete
filterByLink(data)
[83] Fix | Delete
[84] Fix | Delete
var unlooped = filterFound(unloop(data), args)
[85] Fix | Delete
var lite = getLite(unlooped)
[86] Fix | Delete
[87] Fix | Delete
if (silent) return cb(null, data, lite)
[88] Fix | Delete
[89] Fix | Delete
var long = npm.config.get('long')
[90] Fix | Delete
var json = npm.config.get('json')
[91] Fix | Delete
var out
[92] Fix | Delete
if (json) {
[93] Fix | Delete
var seen = new Set()
[94] Fix | Delete
var d = long ? unlooped : lite
[95] Fix | Delete
// the raw data can be circular
[96] Fix | Delete
out = JSON.stringify(d, function (k, o) {
[97] Fix | Delete
if (typeof o === 'object') {
[98] Fix | Delete
if (seen.has(o)) return '[Circular]'
[99] Fix | Delete
seen.add(o)
[100] Fix | Delete
}
[101] Fix | Delete
return o
[102] Fix | Delete
}, 2)
[103] Fix | Delete
} else if (npm.config.get('parseable')) {
[104] Fix | Delete
out = makeParseable(unlooped, long, dir)
[105] Fix | Delete
} else if (data) {
[106] Fix | Delete
out = makeArchy(unlooped, long, dir)
[107] Fix | Delete
}
[108] Fix | Delete
output(out)
[109] Fix | Delete
[110] Fix | Delete
if (args.length && !data._found) process.exitCode = 1
[111] Fix | Delete
[112] Fix | Delete
var er
[113] Fix | Delete
// if any errors were found, then complain and exit status 1
[114] Fix | Delete
if (lite.problems && lite.problems.length) {
[115] Fix | Delete
er = lite.problems.join('\n')
[116] Fix | Delete
}
[117] Fix | Delete
cb(er, data, lite)
[118] Fix | Delete
}
[119] Fix | Delete
[120] Fix | Delete
function pruneNestedExtraneous (data, visited) {
[121] Fix | Delete
visited = visited || []
[122] Fix | Delete
visited.push(data)
[123] Fix | Delete
for (var i in data.dependencies) {
[124] Fix | Delete
if (data.dependencies[i].extraneous) {
[125] Fix | Delete
data.dependencies[i].dependencies = {}
[126] Fix | Delete
} else if (visited.indexOf(data.dependencies[i]) === -1) {
[127] Fix | Delete
pruneNestedExtraneous(data.dependencies[i], visited)
[128] Fix | Delete
}
[129] Fix | Delete
}
[130] Fix | Delete
}
[131] Fix | Delete
[132] Fix | Delete
function filterByEnv (data) {
[133] Fix | Delete
var dev = npm.config.get('dev') || /^dev(elopment)?$/.test(npm.config.get('only'))
[134] Fix | Delete
var production = npm.config.get('production') || /^prod(uction)?$/.test(npm.config.get('only'))
[135] Fix | Delete
var dependencies = {}
[136] Fix | Delete
var devKeys = Object.keys(data.devDependencies || [])
[137] Fix | Delete
var prodKeys = Object.keys(data._dependencies || [])
[138] Fix | Delete
Object.keys(data.dependencies).forEach(function (name) {
[139] Fix | Delete
if (!dev && inList(devKeys, name) && !inList(prodKeys, name) && data.dependencies[name].missing) {
[140] Fix | Delete
return
[141] Fix | Delete
}
[142] Fix | Delete
[143] Fix | Delete
if ((dev && inList(devKeys, name)) || // only --dev
[144] Fix | Delete
(production && inList(prodKeys, name)) || // only --production
[145] Fix | Delete
(!dev && !production)) { // no --production|--dev|--only=xxx
[146] Fix | Delete
dependencies[name] = data.dependencies[name]
[147] Fix | Delete
}
[148] Fix | Delete
})
[149] Fix | Delete
data.dependencies = dependencies
[150] Fix | Delete
}
[151] Fix | Delete
[152] Fix | Delete
function filterByLink (data) {
[153] Fix | Delete
if (npm.config.get('link')) {
[154] Fix | Delete
var dependencies = {}
[155] Fix | Delete
Object.keys(data.dependencies).forEach(function (name) {
[156] Fix | Delete
var dependency = data.dependencies[name]
[157] Fix | Delete
if (dependency.link) {
[158] Fix | Delete
dependencies[name] = dependency
[159] Fix | Delete
}
[160] Fix | Delete
})
[161] Fix | Delete
data.dependencies = dependencies
[162] Fix | Delete
}
[163] Fix | Delete
}
[164] Fix | Delete
[165] Fix | Delete
function alphasort (a, b) {
[166] Fix | Delete
a = a.toLowerCase()
[167] Fix | Delete
b = b.toLowerCase()
[168] Fix | Delete
return a > b ? 1
[169] Fix | Delete
: a < b ? -1 : 0
[170] Fix | Delete
}
[171] Fix | Delete
[172] Fix | Delete
function isCruft (data) {
[173] Fix | Delete
return data.extraneous && data.error && data.error.code === 'ENOTDIR'
[174] Fix | Delete
}
[175] Fix | Delete
[176] Fix | Delete
function getLite (data, noname, depth) {
[177] Fix | Delete
var lite = {}
[178] Fix | Delete
[179] Fix | Delete
if (isCruft(data)) return lite
[180] Fix | Delete
[181] Fix | Delete
var maxDepth = npm.config.get('depth')
[182] Fix | Delete
[183] Fix | Delete
if (typeof depth === 'undefined') depth = 0
[184] Fix | Delete
if (!noname && data.name) lite.name = data.name
[185] Fix | Delete
if (data.version) lite.version = data.version
[186] Fix | Delete
if (data.extraneous) {
[187] Fix | Delete
lite.extraneous = true
[188] Fix | Delete
lite.problems = lite.problems || []
[189] Fix | Delete
lite.problems.push('extraneous: ' + packageId(data) + ' ' + (data.path || ''))
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
if (data.error && data.path !== path.resolve(npm.globalDir, '..') &&
[193] Fix | Delete
(data.error.code !== 'ENOENT' || noname)) {
[194] Fix | Delete
lite.invalid = true
[195] Fix | Delete
lite.problems = lite.problems || []
[196] Fix | Delete
var message = data.error.message
[197] Fix | Delete
lite.problems.push('error in ' + data.path + ': ' + message)
[198] Fix | Delete
}
[199] Fix | Delete
[200] Fix | Delete
if (data._from) {
[201] Fix | Delete
lite.from = data._from
[202] Fix | Delete
}
[203] Fix | Delete
[204] Fix | Delete
if (data._resolved) {
[205] Fix | Delete
lite.resolved = data._resolved
[206] Fix | Delete
}
[207] Fix | Delete
[208] Fix | Delete
if (data.invalid) {
[209] Fix | Delete
lite.invalid = true
[210] Fix | Delete
lite.problems = lite.problems || []
[211] Fix | Delete
lite.problems.push('invalid: ' +
[212] Fix | Delete
packageId(data) +
[213] Fix | Delete
' ' + (data.path || ''))
[214] Fix | Delete
}
[215] Fix | Delete
[216] Fix | Delete
if (data.peerInvalid) {
[217] Fix | Delete
lite.peerInvalid = true
[218] Fix | Delete
lite.problems = lite.problems || []
[219] Fix | Delete
lite.problems.push('peer dep not met: ' +
[220] Fix | Delete
packageId(data) +
[221] Fix | Delete
' ' + (data.path || ''))
[222] Fix | Delete
}
[223] Fix | Delete
[224] Fix | Delete
var deps = (data.dependencies && Object.keys(data.dependencies)) || []
[225] Fix | Delete
if (deps.length) {
[226] Fix | Delete
lite.dependencies = deps.map(function (d) {
[227] Fix | Delete
var dep = data.dependencies[d]
[228] Fix | Delete
if (dep.missing && !dep.optional) {
[229] Fix | Delete
lite.problems = lite.problems || []
[230] Fix | Delete
var p
[231] Fix | Delete
if (data.depth > maxDepth) {
[232] Fix | Delete
p = 'max depth reached: '
[233] Fix | Delete
} else {
[234] Fix | Delete
p = 'missing: '
[235] Fix | Delete
}
[236] Fix | Delete
p += d + '@' + dep.requiredBy +
[237] Fix | Delete
', required by ' +
[238] Fix | Delete
packageId(data)
[239] Fix | Delete
lite.problems.push(p)
[240] Fix | Delete
if (dep.dependencies) {
[241] Fix | Delete
return [d, getLite(dep, true)]
[242] Fix | Delete
} else {
[243] Fix | Delete
return [d, { required: dep.requiredBy, missing: true }]
[244] Fix | Delete
}
[245] Fix | Delete
} else if (dep.peerMissing) {
[246] Fix | Delete
lite.problems = lite.problems || []
[247] Fix | Delete
dep.peerMissing.forEach(function (missing) {
[248] Fix | Delete
var pdm = 'peer dep missing: ' +
[249] Fix | Delete
missing.requires +
[250] Fix | Delete
', required by ' +
[251] Fix | Delete
missing.requiredBy
[252] Fix | Delete
lite.problems.push(pdm)
[253] Fix | Delete
})
[254] Fix | Delete
return [d, { required: dep, peerMissing: true }]
[255] Fix | Delete
} else if (npm.config.get('json')) {
[256] Fix | Delete
if (depth === maxDepth) delete dep.dependencies
[257] Fix | Delete
return [d, getLite(dep, true, depth + 1)]
[258] Fix | Delete
}
[259] Fix | Delete
return [d, getLite(dep, true)]
[260] Fix | Delete
}).reduce(function (deps, d) {
[261] Fix | Delete
if (d[1].problems) {
[262] Fix | Delete
lite.problems = lite.problems || []
[263] Fix | Delete
lite.problems.push.apply(lite.problems, d[1].problems)
[264] Fix | Delete
}
[265] Fix | Delete
deps[d[0]] = d[1]
[266] Fix | Delete
return deps
[267] Fix | Delete
}, {})
[268] Fix | Delete
}
[269] Fix | Delete
return lite
[270] Fix | Delete
}
[271] Fix | Delete
[272] Fix | Delete
function unloop (root) {
[273] Fix | Delete
var queue = [root]
[274] Fix | Delete
var seen = new Set()
[275] Fix | Delete
seen.add(root)
[276] Fix | Delete
[277] Fix | Delete
while (queue.length) {
[278] Fix | Delete
var current = queue.shift()
[279] Fix | Delete
var deps = current.dependencies = current.dependencies || {}
[280] Fix | Delete
Object.keys(deps).forEach(function (d) {
[281] Fix | Delete
var dep = deps[d]
[282] Fix | Delete
if (dep.missing && !dep.dependencies) return
[283] Fix | Delete
if (dep.path && seen.has(dep)) {
[284] Fix | Delete
dep = deps[d] = Object.assign({}, dep)
[285] Fix | Delete
dep.dependencies = {}
[286] Fix | Delete
dep._deduped = path.relative(root.path, dep.path).replace(/node_modules\//g, '')
[287] Fix | Delete
return
[288] Fix | Delete
}
[289] Fix | Delete
seen.add(dep)
[290] Fix | Delete
queue.push(dep)
[291] Fix | Delete
})
[292] Fix | Delete
}
[293] Fix | Delete
[294] Fix | Delete
return root
[295] Fix | Delete
}
[296] Fix | Delete
[297] Fix | Delete
function filterFound (root, args) {
[298] Fix | Delete
if (!args.length) return root
[299] Fix | Delete
if (!root.dependencies) return root
[300] Fix | Delete
[301] Fix | Delete
// Mark all deps
[302] Fix | Delete
var toMark = [root]
[303] Fix | Delete
while (toMark.length) {
[304] Fix | Delete
var markPkg = toMark.shift()
[305] Fix | Delete
var markDeps = markPkg.dependencies
[306] Fix | Delete
if (!markDeps) continue
[307] Fix | Delete
Object.keys(markDeps).forEach(function (depName) {
[308] Fix | Delete
var dep = markDeps[depName]
[309] Fix | Delete
if (dep.peerMissing && !dep._from) return
[310] Fix | Delete
dep._parent = markPkg
[311] Fix | Delete
for (var ii = 0; ii < args.length; ii++) {
[312] Fix | Delete
var argName = args[ii][0]
[313] Fix | Delete
var argVersion = args[ii][1]
[314] Fix | Delete
var argRaw = args[ii][2]
[315] Fix | Delete
var found
[316] Fix | Delete
if (typeof argRaw === 'object') {
[317] Fix | Delete
if (dep.path === argRaw.path) {
[318] Fix | Delete
found = true
[319] Fix | Delete
}
[320] Fix | Delete
} else if (depName === argName && argVersion) {
[321] Fix | Delete
found = semver.satisfies(dep.version, argVersion, true)
[322] Fix | Delete
} else if (depName === argName) {
[323] Fix | Delete
// If version is missing from arg, just do a name match.
[324] Fix | Delete
found = true
[325] Fix | Delete
}
[326] Fix | Delete
if (found) {
[327] Fix | Delete
dep._found = 'explicit'
[328] Fix | Delete
var parent = dep._parent
[329] Fix | Delete
while (parent && !parent._found && !parent._deduped) {
[330] Fix | Delete
parent._found = 'implicit'
[331] Fix | Delete
parent = parent._parent
[332] Fix | Delete
}
[333] Fix | Delete
break
[334] Fix | Delete
}
[335] Fix | Delete
}
[336] Fix | Delete
toMark.push(dep)
[337] Fix | Delete
})
[338] Fix | Delete
}
[339] Fix | Delete
var toTrim = [root]
[340] Fix | Delete
while (toTrim.length) {
[341] Fix | Delete
var trimPkg = toTrim.shift()
[342] Fix | Delete
var trimDeps = trimPkg.dependencies
[343] Fix | Delete
if (!trimDeps) continue
[344] Fix | Delete
trimPkg.dependencies = {}
[345] Fix | Delete
Object.keys(trimDeps).forEach(function (name) {
[346] Fix | Delete
var dep = trimDeps[name]
[347] Fix | Delete
if (!dep._found) return
[348] Fix | Delete
if (dep._found === 'implicit' && dep._deduped) return
[349] Fix | Delete
trimPkg.dependencies[name] = dep
[350] Fix | Delete
toTrim.push(dep)
[351] Fix | Delete
})
[352] Fix | Delete
}
[353] Fix | Delete
return root
[354] Fix | Delete
}
[355] Fix | Delete
[356] Fix | Delete
function makeArchy (data, long, dir) {
[357] Fix | Delete
var out = makeArchy_(data, long, dir, 0)
[358] Fix | Delete
return archy(out, '', { unicode: npm.config.get('unicode') })
[359] Fix | Delete
}
[360] Fix | Delete
[361] Fix | Delete
function makeArchy_ (data, long, dir, depth, parent, d) {
[362] Fix | Delete
if (data.missing) {
[363] Fix | Delete
if (depth - 1 <= npm.config.get('depth')) {
[364] Fix | Delete
// just missing
[365] Fix | Delete
var unmet = 'UNMET ' + (data.optional ? 'OPTIONAL ' : '') + 'DEPENDENCY'
[366] Fix | Delete
if (npm.color) {
[367] Fix | Delete
if (data.optional) {
[368] Fix | Delete
unmet = color.bgBlack(color.yellow(unmet))
[369] Fix | Delete
} else {
[370] Fix | Delete
unmet = color.bgBlack(color.red(unmet))
[371] Fix | Delete
}
[372] Fix | Delete
}
[373] Fix | Delete
var label = data._id || (d + '@' + data.requiredBy)
[374] Fix | Delete
if (data._found === 'explicit' && data._id) {
[375] Fix | Delete
if (npm.color) {
[376] Fix | Delete
label = color.bgBlack(color.yellow(label.trim())) + ' '
[377] Fix | Delete
} else {
[378] Fix | Delete
label = label.trim() + ' '
[379] Fix | Delete
}
[380] Fix | Delete
}
[381] Fix | Delete
return {
[382] Fix | Delete
label: unmet + ' ' + label,
[383] Fix | Delete
nodes: Object.keys(data.dependencies || {})
[384] Fix | Delete
.sort(alphasort).filter(function (d) {
[385] Fix | Delete
return !isCruft(data.dependencies[d])
[386] Fix | Delete
}).map(function (d) {
[387] Fix | Delete
return makeArchy_(sortedObject(data.dependencies[d]), long, dir, depth + 1, data, d)
[388] Fix | Delete
})
[389] Fix | Delete
}
[390] Fix | Delete
} else {
[391] Fix | Delete
return {label: d + '@' + data.requiredBy}
[392] Fix | Delete
}
[393] Fix | Delete
}
[394] Fix | Delete
[395] Fix | Delete
var out = {}
[396] Fix | Delete
if (data._requested && data._requested.type === 'alias') {
[397] Fix | Delete
out.label = `${d}@npm:${data._id}`
[398] Fix | Delete
} else {
[399] Fix | Delete
out.label = data._id || ''
[400] Fix | Delete
}
[401] Fix | Delete
if (data._found === 'explicit' && data._id) {
[402] Fix | Delete
if (npm.color) {
[403] Fix | Delete
out.label = color.bgBlack(color.yellow(out.label.trim())) + ' '
[404] Fix | Delete
} else {
[405] Fix | Delete
out.label = out.label.trim() + ' '
[406] Fix | Delete
}
[407] Fix | Delete
}
[408] Fix | Delete
if (data.link) out.label += ' -> ' + data.link
[409] Fix | Delete
[410] Fix | Delete
if (data._deduped) {
[411] Fix | Delete
if (npm.color) {
[412] Fix | Delete
out.label += ' ' + color.brightBlack('deduped')
[413] Fix | Delete
} else {
[414] Fix | Delete
out.label += ' deduped'
[415] Fix | Delete
}
[416] Fix | Delete
}
[417] Fix | Delete
[418] Fix | Delete
if (data.invalid) {
[419] Fix | Delete
if (data.realName !== data.name) out.label += ' (' + data.realName + ')'
[420] Fix | Delete
var invalid = 'invalid'
[421] Fix | Delete
if (npm.color) invalid = color.bgBlack(color.red(invalid))
[422] Fix | Delete
out.label += ' ' + invalid
[423] Fix | Delete
}
[424] Fix | Delete
[425] Fix | Delete
if (data.peerInvalid) {
[426] Fix | Delete
var peerInvalid = 'peer invalid'
[427] Fix | Delete
if (npm.color) peerInvalid = color.bgBlack(color.red(peerInvalid))
[428] Fix | Delete
out.label += ' ' + peerInvalid
[429] Fix | Delete
}
[430] Fix | Delete
[431] Fix | Delete
if (data.peerMissing) {
[432] Fix | Delete
var peerMissing = 'UNMET PEER DEPENDENCY'
[433] Fix | Delete
[434] Fix | Delete
if (npm.color) peerMissing = color.bgBlack(color.red(peerMissing))
[435] Fix | Delete
out.label = peerMissing + ' ' + out.label
[436] Fix | Delete
}
[437] Fix | Delete
[438] Fix | Delete
if (data.extraneous && data.path !== dir) {
[439] Fix | Delete
var extraneous = 'extraneous'
[440] Fix | Delete
if (npm.color) extraneous = color.bgBlack(color.green(extraneous))
[441] Fix | Delete
out.label += ' ' + extraneous
[442] Fix | Delete
}
[443] Fix | Delete
[444] Fix | Delete
if (data.error && depth) {
[445] Fix | Delete
var message = data.error.message
[446] Fix | Delete
if (message.indexOf('\n')) message = message.slice(0, message.indexOf('\n'))
[447] Fix | Delete
var error = 'error: ' + message
[448] Fix | Delete
if (npm.color) error = color.bgRed(color.brightWhite(error))
[449] Fix | Delete
out.label += ' ' + error
[450] Fix | Delete
}
[451] Fix | Delete
[452] Fix | Delete
// add giturl to name@version
[453] Fix | Delete
if (data._resolved) {
[454] Fix | Delete
try {
[455] Fix | Delete
var type = npa(data._resolved).type
[456] Fix | Delete
var isGit = type === 'git' || type === 'hosted'
[457] Fix | Delete
if (isGit) {
[458] Fix | Delete
out.label += ' (' + data._resolved + ')'
[459] Fix | Delete
}
[460] Fix | Delete
} catch (ex) {
[461] Fix | Delete
// npa threw an exception then it ain't git so whatev
[462] Fix | Delete
}
[463] Fix | Delete
}
[464] Fix | Delete
[465] Fix | Delete
if (long) {
[466] Fix | Delete
if (dir === data.path) out.label += '\n' + dir
[467] Fix | Delete
out.label += '\n' + getExtras(data)
[468] Fix | Delete
} else if (dir === data.path) {
[469] Fix | Delete
if (out.label) out.label += ' '
[470] Fix | Delete
out.label += dir
[471] Fix | Delete
}
[472] Fix | Delete
[473] Fix | Delete
// now all the children.
[474] Fix | Delete
out.nodes = []
[475] Fix | Delete
if (depth <= npm.config.get('depth')) {
[476] Fix | Delete
out.nodes = Object.keys(data.dependencies || {})
[477] Fix | Delete
.sort(alphasort).filter(function (d) {
[478] Fix | Delete
return !isCruft(data.dependencies[d])
[479] Fix | Delete
}).map(function (d) {
[480] Fix | Delete
return makeArchy_(sortedObject(data.dependencies[d]), long, dir, depth + 1, data, d)
[481] Fix | Delete
})
[482] Fix | Delete
}
[483] Fix | Delete
[484] Fix | Delete
if (out.nodes.length === 0 && data.path === dir) {
[485] Fix | Delete
out.nodes = ['(empty)']
[486] Fix | Delete
}
[487] Fix | Delete
[488] Fix | Delete
return out
[489] Fix | Delete
}
[490] Fix | Delete
[491] Fix | Delete
function getExtras (data) {
[492] Fix | Delete
var extras = []
[493] Fix | Delete
[494] Fix | Delete
if (data.description) extras.push(data.description)
[495] Fix | Delete
if (data.repository) extras.push(data.repository.url)
[496] Fix | Delete
if (data.homepage) extras.push(data.homepage)
[497] Fix | Delete
if (data._from) {
[498] Fix | Delete
var from = data._from
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function