X7ROOT File Manager
Current Path:
/opt/alt/alt-nodejs6/root/usr/lib/node_modules/npm/lib
opt
/
alt
/
alt-nodejs6
/
root
/
usr
/
lib
/
node_modules
/
npm
/
lib
/
??
..
??
access.js
(3.23 KB)
??
adduser.js
(3.98 KB)
??
bin.js
(515 B)
??
bugs.js
(857 B)
??
build.js
(8.5 KB)
??
cache
??
cache.js
(10.17 KB)
??
completion.js
(7.06 KB)
??
config
??
config.js
(8.27 KB)
??
dedupe.js
(5.27 KB)
??
deprecate.js
(1.4 KB)
??
dist-tag.js
(3.67 KB)
??
docs.js
(1.03 KB)
??
edit.js
(985 B)
??
explore.js
(1.63 KB)
??
fetch-package-metadata.js
(11.5 KB)
??
fetch-package-metadata.md
(1.76 KB)
??
get.js
(235 B)
??
help-search.js
(5.65 KB)
??
help.js
(6.19 KB)
??
init.js
(1.27 KB)
??
install
??
install-test.js
(507 B)
??
install.js
(25.49 KB)
??
link.js
(5.55 KB)
??
logout.js
(1.1 KB)
??
ls.js
(13.94 KB)
??
npm.js
(11.23 KB)
??
outdated.js
(12.1 KB)
??
owner.js
(7.55 KB)
??
pack.js
(1.79 KB)
??
ping.js
(556 B)
??
prefix.js
(330 B)
??
prune.js
(1.5 KB)
??
publish.js
(5.02 KB)
??
rebuild.js
(2.11 KB)
??
repo.js
(1.43 KB)
??
restart.js
(64 B)
??
root.js
(316 B)
??
run-script.js
(5.16 KB)
??
search.js
(7.76 KB)
??
set.js
(276 B)
??
shrinkwrap.js
(6.54 KB)
??
star.js
(1.17 KB)
??
stars.js
(1.1 KB)
??
start.js
(62 B)
??
stop.js
(61 B)
??
substack.js
(509 B)
??
tag.js
(1.08 KB)
??
team.js
(1.41 KB)
??
test.js
(294 B)
??
unbuild.js
(3.97 KB)
??
uninstall.js
(2.31 KB)
??
unpublish.js
(3.55 KB)
??
update.js
(1.76 KB)
??
utils
??
version.js
(7.71 KB)
??
view.js
(9.12 KB)
??
visnup.js
(4.01 KB)
??
whoami.js
(1.42 KB)
??
xmas.js
(1.57 KB)
Editing: dedupe.js
var util = require('util') var path = require('path') var validate = require('aproba') var without = require('lodash.without') var asyncMap = require('slide').asyncMap var chain = require('slide').chain var npa = require('npm-package-arg') var log = require('npmlog') var npm = require('./npm.js') var Installer = require('./install.js').Installer var findRequirement = require('./install/deps.js').findRequirement var earliestInstallable = require('./install/deps.js').earliestInstallable var checkPermissions = require('./install/check-permissions.js') var decomposeActions = require('./install/decompose-actions.js') var loadExtraneous = require('./install/deps.js').loadExtraneous var filterInvalidActions = require('./install/filter-invalid-actions.js') var recalculateMetadata = require('./install/deps.js').recalculateMetadata var sortActions = require('./install/diff-trees.js').sortActions var moduleName = require('./utils/module-name.js') var packageId = require('./utils/package-id.js') var childPath = require('./utils/child-path.js') var usage = require('./utils/usage') module.exports = dedupe module.exports.Deduper = Deduper dedupe.usage = usage( 'dedupe', 'npm dedupe' ) function dedupe (args, cb) { validate('AF', arguments) // the /path/to/node_modules/.. var where = path.resolve(npm.dir, '..') var dryrun = false if (npm.command.match(/^find/)) dryrun = true if (npm.config.get('dry-run')) dryrun = true new Deduper(where, dryrun).run(cb) } function Deduper (where, dryrun) { validate('SB', arguments) Installer.call(this, where, dryrun, []) this.noPackageJsonOk = true this.topLevelLifecycles = false } util.inherits(Deduper, Installer) Deduper.prototype.normalizeTree = function (log, cb) { validate('OF', arguments) log.silly('dedupe', 'normalizeTree') // If we're looking globally only look at the one package we're operating on if (npm.config.get('global')) { var args = this.args this.currentTree.children = this.currentTree.children.filter(function (child) { return args.filter(function (arg) { return arg === moduleName(child) }).length }) } Installer.prototype.normalizeTree.call(this, log, cb) } Deduper.prototype.loadIdealTree = function (cb) { validate('F', arguments) log.silly('install', 'loadIdealTree') var self = this chain([ [this.newTracker(this.progress.loadIdealTree, 'cloneCurrentTree')], [this, this.cloneCurrentTreeToIdealTree], [this, this.finishTracker, 'cloneCurrentTree'], [this.newTracker(this.progress.loadIdealTree, 'loadAllDepsIntoIdealTree', 10)], [ function (next) { loadExtraneous(self.idealTree, self.progress.loadAllDepsIntoIdealTree, next) } ], [this, this.finishTracker, 'loadAllDepsIntoIdealTree'], [this, function (next) { recalculateMetadata(this.idealTree, log, next) }] ], cb) } Deduper.prototype.generateActionsToTake = function (cb) { validate('F', arguments) log.silly('dedupe', 'generateActionsToTake') chain([ [this.newTracker(log, 'hoist', 1)], [hoistChildren, this.idealTree, this.differences], [this, this.finishTracker, 'hoist'], [this.newTracker(log, 'sort-actions', 1)], [this, function (next) { this.differences = sortActions(this.differences) next() }], [this, this.finishTracker, 'sort-actions'], [filterInvalidActions, this.where, this.differences], [checkPermissions, this.differences], [decomposeActions, this.differences, this.todo] ], cb) } function move (node, hoistTo, diff) { node.parent.children = without(node.parent.children, node) hoistTo.children.push(node) node.fromPath = node.path node.path = childPath(hoistTo.path, node) node.parent = hoistTo if (!diff.filter(function (action) { return action[0] === 'move' && action[1] === node }).length) { diff.push(['move', node]) } } function moveRemainingChildren (node, diff) { node.children.forEach(function (child) { move(child, node, diff) moveRemainingChildren(child, diff) }) } function remove (child, diff, done) { remove_(child, diff, {}, done) } function remove_ (child, diff, seen, done) { if (seen[child.path]) return done() seen[child.path] = true diff.push(['remove', child]) child.parent.children = without(child.parent.children, child) asyncMap(child.children, function (child, next) { remove_(child, diff, seen, next) }, done) } function hoistChildren (tree, diff, next) { hoistChildren_(tree, diff, {}, next) } function hoistChildren_ (tree, diff, seen, next) { validate('OAOF', arguments) if (seen[tree.path]) return next() seen[tree.path] = true asyncMap(tree.children, function (child, done) { if (!tree.parent) return hoistChildren_(child, diff, seen, done) var better = findRequirement(tree.parent, moduleName(child), child.package._requested || npa(packageId(child))) if (better) { return chain([ [remove, child, diff], [recalculateMetadata, tree, log] ], done) } var hoistTo = earliestInstallable(tree, tree.parent, child.package) if (hoistTo) { move(child, hoistTo, diff) chain([ [recalculateMetadata, hoistTo, log], [hoistChildren_, child, diff, seen], [ function (next) { moveRemainingChildren(child, diff) next() } ] ], done) } else { done() } }, next) }
Upload File
Create Folder