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

Method execWorkspaces

deps/npm/lib/commands/run.js:50–85  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

48 }
49
50 async execWorkspaces (args) {
51 await this.setWorkspaces()
52
53 const ws = [...this.workspaces.entries()]
54 for (const [workspace, path] of ws) {
55 const last = path === ws.at(-1)[1]
56
57 if (!args.length) {
58 const newline = await this.#list(path, { workspace })
59 if (newline && !last) {
60 output.standard()
61 }
62 continue
63 }
64
65 const pkg = await pkgJson.normalize(path).then(p => p.content)
66 try {
67 await this.#run(args, { path, pkg, workspace })
68 } catch (e) {
69 const err = getError(e, { npm: this.npm, command: null })
70 outputError({
71 ...err,
72 error: [
73 ['', `Lifecycle script \`${args[0]}\` failed with error:`],
74 ...err.error,
75 ['workspace', pkg._id || pkg.name],
76 ['location', path],
77 ],
78 })
79 process.exitCode = err.exitCode
80 if (!last) {
81 output.error('')
82 }
83 }
84 }
85 }
86
87 async #run ([event, ...args], { path, pkg, workspace }) {
88 const runScript = require('@npmcli/run-script')

Callers

nothing calls this directly

Calls 9

#listMethod · 0.95
#runMethod · 0.95
outputErrorFunction · 0.85
setWorkspacesMethod · 0.80
getErrorFunction · 0.50
entriesMethod · 0.45
atMethod · 0.45
thenMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected