Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/smanonr..../lib/node_mod.../npm/lib
File: uninstall.js
'use strict'
[0] Fix | Delete
// remove a package.
[1] Fix | Delete
[2] Fix | Delete
module.exports = uninstall
[3] Fix | Delete
[4] Fix | Delete
const path = require('path')
[5] Fix | Delete
const validate = require('aproba')
[6] Fix | Delete
const readJson = require('read-package-json')
[7] Fix | Delete
const iferr = require('iferr')
[8] Fix | Delete
const npm = require('./npm.js')
[9] Fix | Delete
const Installer = require('./install.js').Installer
[10] Fix | Delete
const getSaveType = require('./install/save.js').getSaveType
[11] Fix | Delete
const removeDeps = require('./install/deps.js').removeDeps
[12] Fix | Delete
const log = require('npmlog')
[13] Fix | Delete
const usage = require('./utils/usage')
[14] Fix | Delete
[15] Fix | Delete
uninstall.usage = usage(
[16] Fix | Delete
'uninstall',
[17] Fix | Delete
'npm uninstall [<@scope>/]<pkg>[@<version>]... [--save-prod|--save-dev|--save-optional] [--no-save]'
[18] Fix | Delete
)
[19] Fix | Delete
[20] Fix | Delete
uninstall.completion = require('./utils/completion/installed-shallow.js')
[21] Fix | Delete
[22] Fix | Delete
function uninstall (args, cb) {
[23] Fix | Delete
validate('AF', arguments)
[24] Fix | Delete
// the /path/to/node_modules/..
[25] Fix | Delete
const dryrun = !!npm.config.get('dry-run')
[26] Fix | Delete
[27] Fix | Delete
if (args.length === 1 && args[0] === '.') args = []
[28] Fix | Delete
[29] Fix | Delete
const where = npm.config.get('global') || !args.length
[30] Fix | Delete
? path.resolve(npm.globalDir, '..')
[31] Fix | Delete
: npm.prefix
[32] Fix | Delete
[33] Fix | Delete
args = args.filter(function (a) {
[34] Fix | Delete
return path.resolve(a) !== where
[35] Fix | Delete
})
[36] Fix | Delete
[37] Fix | Delete
if (args.length) {
[38] Fix | Delete
new Uninstaller(where, dryrun, args).run(cb)
[39] Fix | Delete
} else {
[40] Fix | Delete
// remove this package from the global space, if it's installed there
[41] Fix | Delete
readJson(path.resolve(npm.localPrefix, 'package.json'), function (er, pkg) {
[42] Fix | Delete
if (er && er.code !== 'ENOENT' && er.code !== 'ENOTDIR') return cb(er)
[43] Fix | Delete
if (er) return cb(uninstall.usage)
[44] Fix | Delete
new Uninstaller(where, dryrun, [pkg.name]).run(cb)
[45] Fix | Delete
})
[46] Fix | Delete
}
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
class Uninstaller extends Installer {
[50] Fix | Delete
constructor (where, dryrun, args) {
[51] Fix | Delete
super(where, dryrun, args)
[52] Fix | Delete
this.remove = []
[53] Fix | Delete
}
[54] Fix | Delete
[55] Fix | Delete
loadArgMetadata (next) {
[56] Fix | Delete
this.args = this.args.map(function (arg) { return {name: arg} })
[57] Fix | Delete
next()
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
loadAllDepsIntoIdealTree (cb) {
[61] Fix | Delete
validate('F', arguments)
[62] Fix | Delete
this.remove = this.args
[63] Fix | Delete
this.args = []
[64] Fix | Delete
log.silly('uninstall', 'loadAllDepsIntoIdealTree')
[65] Fix | Delete
const saveDeps = getSaveType()
[66] Fix | Delete
[67] Fix | Delete
super.loadAllDepsIntoIdealTree(iferr(cb, () => {
[68] Fix | Delete
removeDeps(this.remove, this.idealTree, saveDeps, cb)
[69] Fix | Delete
}))
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
// no top level lifecycles on rm
[73] Fix | Delete
runPreinstallTopLevelLifecycles (cb) { cb() }
[74] Fix | Delete
runPostinstallTopLevelLifecycles (cb) { cb() }
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
module.exports.Uninstaller = Uninstaller
[78] Fix | Delete
[79] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function