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

Method logOptions

deps/npm/lib/trust-cmd.js:82–148  ·  view source on GitHub ↗
(options, pad = true)

Source from the content-addressed store, hash-verified

80 }
81
82 logOptions (options, pad = true) {
83 const { values, warnings, fromPackageJson, urls, permissions } = { warnings: [], ...options }
84 if (warnings && warnings.length > 0) {
85 for (const warningMsg of warnings) {
86 log.warn('trust', warningMsg)
87 }
88 }
89
90 const json = this.config.get('json')
91 if (json) {
92 const jsonValues = { ...options.values }
93 if (permissions) {
94 jsonValues.permissions = permissions
95 }
96 // Disable redaction: trust config values (e.g. CircleCI UUIDs) are not secrets
97 output.standard(JSON.stringify(jsonValues, null, 2), { [META]: true, redact: false })
98 return
99 }
100
101 const chalk = this.npm.chalk
102 const { type, id, ...rest } = values || {}
103
104 if (values) {
105 const lines = []
106 if (type) {
107 lines.push(`type: ${chalk.green(type)}`)
108 }
109 if (id) {
110 lines.push(`id: ${chalk.green(id)}`)
111 }
112 for (const [key, value] of Object.entries(rest)) {
113 if (value !== null && value !== undefined) {
114 const parts = [
115 `${chalk.reset(key)}: ${chalk.green(value)}`,
116 ]
117 if (fromPackageJson && fromPackageJson[key]) {
118 parts.push(`(${chalk.yellow(`from package.json`)})`)
119 }
120 lines.push(parts.join(' '))
121 }
122 }
123 const formattedPermissions = TrustCommand.formatPermissions(permissions)
124 if (formattedPermissions) {
125 lines.push(`${chalk.reset('permissions')}: ${chalk.green(formattedPermissions)}`)
126 }
127 if (pad) {
128 output.standard()
129 }
130 output.standard(lines.join('\n'), { [META]: true, redact: false })
131 // Print URLs on their own lines after config, following the same order as rest keys
132 if (urls) {
133 const urlLines = []
134 for (const key of Object.keys(rest)) {
135 if (urls[key]) {
136 urlLines.push(chalk.blue(urls[key]))
137 }
138 }
139 if (urlLines.length > 0) {

Callers 3

createConfigCommandMethod · 0.95
displayResponseBodyMethod · 0.95
trust-cmd.jsFile · 0.80

Calls 11

warnMethod · 0.80
yellowMethod · 0.80
formatPermissionsMethod · 0.80
blueMethod · 0.80
getMethod · 0.65
keysMethod · 0.65
pushMethod · 0.45
greenMethod · 0.45
entriesMethod · 0.45
resetMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected