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

Method exec

deps/npm/lib/commands/pkg.js:28–49  ·  view source on GitHub ↗
(args, { path = this.npm.localPrefix, workspace } = {})

Source from the content-addressed store, hash-verified

26 static ignoreImplicitWorkspace = false
27
28 async exec (args, { path = this.npm.localPrefix, workspace } = {}) {
29 if (this.npm.global) {
30 throw Object.assign(
31 new Error(`There's no package.json file to manage on global mode`),
32 { code: 'EPKGGLOBAL' }
33 )
34 }
35
36 const [cmd, ..._args] = args
37 switch (cmd) {
38 case 'get':
39 return this.get(_args, { path, workspace })
40 case 'set':
41 return this.set(_args, { path, workspace }).then(p => p.save())
42 case 'delete':
43 return this.delete(_args, { path, workspace }).then(p => p.save())
44 case 'fix':
45 return PackageJson.fix(path).then(p => p.save())
46 default:
47 throw this.usageError()
48 }
49 }
50
51 async execWorkspaces (args) {
52 await this.setWorkspaces()

Callers 1

execWorkspacesMethod · 0.95

Calls 8

getMethod · 0.95
setMethod · 0.95
deleteMethod · 0.95
assignMethod · 0.80
fixMethod · 0.80
usageErrorMethod · 0.80
thenMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected