MCPcopy Create free account
hub / github.com/npm/cli / listWorkspaces

Method listWorkspaces

lib/commands/version.js:136–149  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

134 }
135
136 async listWorkspaces () {
137 const results = {}
138 await this.setWorkspaces()
139 for (const path of this.workspacePaths) {
140 const pj = resolve(path, 'package.json')
141 // setWorkspaces has already parsed package.json so we know it won't error
142 const pkg = await readFile(pj, 'utf8').then(data => JSON.parse(data))
143
144 if (pkg.name && pkg.version) {
145 results[pkg.name] = pkg.version
146 }
147 }
148 return this.list(results)
149 }
150}
151
152module.exports = Version

Callers 1

execWorkspacesMethod · 0.95

Calls 5

listMethod · 0.95
resolveFunction · 0.85
readFileFunction · 0.85
setWorkspacesMethod · 0.80
parseMethod · 0.80

Tested by

no test coverage detected