summaryrefslogtreecommitdiff
path: root/deps/npm/lib/uninstall.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/lib/uninstall.js')
-rw-r--r--deps/npm/lib/uninstall.js82
1 files changed, 42 insertions, 40 deletions
diff --git a/deps/npm/lib/uninstall.js b/deps/npm/lib/uninstall.js
index 9e3d91ac40..c181fdc4e8 100644
--- a/deps/npm/lib/uninstall.js
+++ b/deps/npm/lib/uninstall.js
@@ -2,24 +2,21 @@
// remove a package.
module.exports = uninstall
-module.exports.Uninstaller = Uninstaller
-var util = require('util')
-var path = require('path')
-var validate = require('aproba')
-var chain = require('slide').chain
-var readJson = require('read-package-json')
-var npm = require('./npm.js')
-var Installer = require('./install.js').Installer
-var getSaveType = require('./install/save.js').getSaveType
-var removeDeps = require('./install/deps.js').removeDeps
-var loadExtraneous = require('./install/deps.js').loadExtraneous
-var log = require('npmlog')
-var usage = require('./utils/usage')
+const path = require('path')
+const validate = require('aproba')
+const readJson = require('read-package-json')
+const iferr = require('iferr')
+const npm = require('./npm.js')
+const Installer = require('./install.js').Installer
+const getSaveType = require('./install/save.js').getSaveType
+const removeDeps = require('./install/deps.js').removeDeps
+const log = require('npmlog')
+const usage = require('./utils/usage')
uninstall.usage = usage(
'uninstall',
- 'npm uninstall [<@scope>/]<pkg>[@<version>]... [--save|--save-dev|--save-optional]'
+ 'npm uninstall [<@scope>/]<pkg>[@<version>]... [--save-prod|--save-dev|--save-optional] [--no-save]'
)
uninstall.completion = require('./utils/completion/installed-shallow.js')
@@ -27,17 +24,18 @@ uninstall.completion = require('./utils/completion/installed-shallow.js')
function uninstall (args, cb) {
validate('AF', arguments)
// the /path/to/node_modules/..
- var dryrun = !!npm.config.get('dry-run')
+ const dryrun = !!npm.config.get('dry-run')
if (args.length === 1 && args[0] === '.') args = []
- args = args.filter(function (a) {
- return path.resolve(a) !== where
- })
- var where = npm.config.get('global') || !args.length
+ const where = npm.config.get('global') || !args.length
? path.resolve(npm.globalDir, '..')
: npm.prefix
+ args = args.filter(function (a) {
+ return path.resolve(a) !== where
+ })
+
if (args.length) {
new Uninstaller(where, dryrun, args).run(cb)
} else {
@@ -50,29 +48,33 @@ function uninstall (args, cb) {
}
}
-function Uninstaller (where, dryrun, args) {
- validate('SBA', arguments)
- Installer.call(this, where, dryrun, args)
-}
-util.inherits(Uninstaller, Installer)
+class Uninstaller extends Installer {
+ constructor (where, dryrun, args) {
+ super(where, dryrun, args)
+ this.remove = []
+ this.fakeChildren = false
+ }
-Uninstaller.prototype.loadArgMetadata = function (next) {
- this.args = this.args.map(function (arg) { return {name: arg} })
- next()
-}
+ loadArgMetadata (next) {
+ this.args = this.args.map(function (arg) { return {name: arg} })
+ next()
+ }
-Uninstaller.prototype.loadAllDepsIntoIdealTree = function (cb) {
- validate('F', arguments)
- log.silly('uninstall', 'loadAllDepsIntoIdealTree')
- var saveDeps = getSaveType()
+ loadAllDepsIntoIdealTree (cb) {
+ validate('F', arguments)
+ this.remove = this.args
+ this.args = []
+ log.silly('uninstall', 'loadAllDepsIntoIdealTree')
+ const saveDeps = getSaveType()
- var cg = this.progress['loadIdealTree:loadAllDepsIntoIdealTree']
- var steps = []
- steps.push(
- [removeDeps, this.args, this.idealTree, saveDeps, cg.newGroup('removeDeps')],
- [loadExtraneous, this.idealTree, cg.newGroup('loadExtraneous')])
- chain(steps, cb)
+ super.loadAllDepsIntoIdealTree(iferr(cb, () => {
+ removeDeps(this.remove, this.idealTree, saveDeps, cb)
+ }))
+ }
+
+ // no top level lifecycles on rm
+ runPreinstallTopLevelLifecycles (cb) { cb() }
+ runPostinstallTopLevelLifecycles (cb) { cb() }
}
-Uninstaller.prototype.runPreinstallTopLevelLifecycles = function (cb) { cb() }
-Uninstaller.prototype.runPostinstallTopLevelLifecycles = function (cb) { cb() }
+module.exports.Uninstaller = Uninstaller