MCPcopy Index your code
hub / github.com/nodejs/node / #viewPackage

Method #viewPackage

deps/npm/lib/commands/view.js:101–128  ·  view source on GitHub ↗
(name, args, { workspace } = {})

Source from the content-addressed store, hash-verified

99 }
100
101 async #viewPackage (name, args, { workspace } = {}) {
102 const wholePackument = !args.length
103 const json = this.npm.config.get('json')
104
105 // If we are viewing many packages and outputting individual fields then output the name before doing any async activity
106 if (!json && !wholePackument && workspace) {
107 output.standard(`${name}:`)
108 }
109
110 const [pckmnt, data] = await this.#getData(name, args, wholePackument)
111
112 if (!json && wholePackument) {
113 // pretty view (entire packument)
114 for (const v of data) {
115 output.standard(this.#prettyView(pckmnt, Object.values(v)[0][Queryable.ALL]))
116 }
117 return
118 }
119
120 const res = this.#packageOutput(cleanData(data, wholePackument), pckmnt._id)
121 if (res) {
122 if (json) {
123 output.buffer(workspace ? { [name]: res } : res)
124 } else {
125 output.standard(res)
126 }
127 }
128 }
129
130 async #getData (pkg, args) {
131 const spec = npa(pkg)

Callers 2

execMethod · 0.95
execWorkspacesMethod · 0.95

Calls 7

#getDataMethod · 0.95
#prettyViewMethod · 0.95
#packageOutputMethod · 0.95
cleanDataFunction · 0.85
getMethod · 0.65
valuesMethod · 0.45
bufferMethod · 0.45

Tested by

no test coverage detected