MCPcopy Create free account
hub / github.com/npm/cli / #pretty

Method #pretty

lib/commands/outdated.js:224–255  ·  view source on GitHub ↗
(list)

Source from the content-addressed store, hash-verified

222 // formatting functions
223
224 #pretty (list) {
225 if (!list.length) {
226 return
227 }
228
229 const long = this.npm.config.get('long')
230 const { bold, yellow, red, cyan, blue } = this.npm.chalk
231
232 return table([
233 [
234 'Package',
235 'Current',
236 'Wanted',
237 'Latest',
238 'Location',
239 'Depended by',
240 ...long ? ['Package Type', 'Homepage', 'Depended By Location'] : [],
241 ].map(h => bold.underline(h)),
242 ...list.map((d) => [
243 d.current === d.wanted ? yellow(d.name) : red(d.name),
244 d.current ?? 'MISSING',
245 cyan(d.wanted),
246 blue(d.latest),
247 d.location ?? '-',
248 d.workspaceDependent ? blue(d.workspaceDependent) : d.dependent,
249 ...long ? [d.type, blue(d.homepage ?? ''), d.dependedByLocation] : [],
250 ]),
251 ], {
252 align: ['l', 'r', 'r', 'r', 'l'],
253 stringLength: s => stripVTControlCharacters(s).length,
254 })
255 }
256
257 // --parseable creates output like this:
258 // <fullpath>:<name@wanted>:<name@installed>:<name@latest>:<dependedby>

Callers 1

execMethod · 0.95

Calls 2

redFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected