(args)
| 17 | } |
| 18 | |
| 19 | async exec (args) { |
| 20 | if (!args.length) { |
| 21 | if (!this.npm.global) { |
| 22 | throw new Error('Must provide a package name to remove') |
| 23 | } else { |
| 24 | try { |
| 25 | const { content: pkg } = await pkgJson.normalize(this.npm.localPrefix) |
| 26 | args.push(pkg.name) |
| 27 | } catch (er) { |
| 28 | if (er.code !== 'ENOENT' && er.code !== 'ENOTDIR') { |
| 29 | throw er |
| 30 | } else { |
| 31 | throw this.usageError() |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | // the /path/to/node_modules/.. |
| 38 | const path = this.npm.global |
| 39 | ? resolve(this.npm.globalDir, '..') |
| 40 | : this.npm.localPrefix |
| 41 | |
| 42 | const Arborist = require('@npmcli/arborist') |
| 43 | const { policy: allowScriptsPolicy } = await resolveAllowScripts(this.npm) |
| 44 | const opts = { |
| 45 | ...this.npm.flatOptions, |
| 46 | path, |
| 47 | rm: args, |
| 48 | workspaces: this.workspaceNames, |
| 49 | allowScripts: allowScriptsPolicy, |
| 50 | } |
| 51 | const arb = new Arborist(opts) |
| 52 | await arb.reify(opts) |
| 53 | await reifyFinish(this.npm, arb) |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | module.exports = Uninstall |
nothing calls this directly
no test coverage detected