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

Method exec

deps/npm/lib/commands/pack.js:25–73  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

23 static ignoreImplicitWorkspace = false
24
25 async exec (args) {
26 if (args.length === 0) {
27 args = ['.']
28 }
29
30 const unicode = this.npm.config.get('unicode')
31 const json = this.npm.config.get('json')
32
33 const Arborist = require('@npmcli/arborist')
34 // Get the manifests and filenames first so we can bail early on manifest errors before making any tarballs
35 const manifests = []
36 for (const arg of args) {
37 const spec = npa(arg)
38 const manifest = await pacote.manifest(spec, {
39 ...this.npm.flatOptions,
40 Arborist,
41 preferOnline: true,
42 _isRoot: true,
43 })
44 if (!manifest._id) {
45 throw new Error('Invalid package, must have name and version')
46 }
47 manifests.push({ arg, manifest })
48 }
49
50 // Load tarball names up for printing afterward to isolate from the noise generated during packing
51 const tarballs = []
52 for (const { arg, manifest } of manifests) {
53 const tarballData = await libpack(arg, {
54 ...this.npm.flatOptions,
55 foregroundScripts: this.npm.config.isDefault('foreground-scripts')
56 ? true
57 : this.npm.config.get('foreground-scripts'),
58 preferOnline: true,
59 prefix: this.npm.localPrefix,
60 workspaces: this.workspacePaths,
61 })
62 tarballs.push(await getContents(manifest, tarballData))
63 }
64
65 for (const [index, tar] of Object.entries(tarballs)) {
66 // XXX(BREAKING_CHANGE): publish outputs a json object with package names as keys.
67 // Pack should do the same here instead of an array
68 logTar(tar, { unicode, json, key: index })
69 if (!json) {
70 output.standard(tar.filename.replace(/^@/, '').replace(/\//, '-'))
71 }
72 }
73 }
74
75 async execWorkspaces (args) {
76 // If they either ask for nothing, or explicitly include '.' in the args, we effectively translate that into each workspace requested

Callers 1

execWorkspacesMethod · 0.95

Calls 6

getContentsFunction · 0.85
logTarFunction · 0.85
getMethod · 0.65
requireFunction · 0.50
pushMethod · 0.45
entriesMethod · 0.45

Tested by

no test coverage detected