MCPcopy Index your code
hub / github.com/nodejs/node / exec

Method exec

deps/npm/lib/commands/uninstall.js:19–54  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

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
57module.exports = Uninstall

Callers

nothing calls this directly

Calls 7

reifyMethod · 0.95
resolveAllowScriptsFunction · 0.85
reifyFinishFunction · 0.85
usageErrorMethod · 0.80
resolveFunction · 0.50
requireFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected