A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/npm/cli/commit/71cbd91b6f01875a99eeae989ea67489bdd0178d below:

hide banner for exec and explore (#7421) · npm/cli@71cbd91 · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+35

-21

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+35

-21

lines changed Original file line number Diff line number Diff line change

@@ -93,14 +93,7 @@ class Npm {

93 93

}

94 94 95 95

async load () {

96 -

return time.start('npm:load', async () => {

97 -

const { exec } = await this.#load()

98 -

return {

99 -

exec,

100 -

command: this.argv.shift(),

101 -

args: this.argv,

102 -

}

103 -

})

96 +

return time.start('npm:load', () => this.#load())

104 97

}

105 98 106 99

get loaded () {

@@ -165,7 +158,26 @@ class Npm {

165 158 166 159

await time.start('npm:load:configload', () => this.config.load())

167 160 161 +

// npm --versions

162 +

if (this.config.get('versions', 'cli')) {

163 +

this.argv = ['version']

164 +

this.config.set('usage', false, 'cli')

165 +

} else {

166 +

this.argv = [...this.config.parsedArgv.remain]

167 +

}

168 + 169 +

// Remove first argv since that is our command as typed

170 +

// Note that this might not be the actual name of the command

171 +

// due to aliases, etc. But we use the raw form of it later

172 +

// in user output so it must be preserved as is.

173 +

const commandArg = this.argv.shift()

174 + 175 +

// This is the actual name of the command that will be run or

176 +

// undefined if deref could not find a match

177 +

const command = deref(commandArg)

178 + 168 179

await this.#display.load({

180 +

command,

169 181

loglevel: this.config.get('loglevel'),

170 182

stdoutColor: this.color,

171 183

stderrColor: this.logColor,

@@ -202,9 +214,10 @@ class Npm {

202 214 203 215

// note: this MUST be shorter than the actual argv length, because it

204 216

// uses the same memory, so node will truncate it if it's too long.

217 +

// We time this because setting process.title is slow sometimes but we

218 +

// have to do it for security reasons. But still helpful to know how slow it is.

205 219

time.start('npm:load:setTitle', () => {

206 220

const { parsedArgv: { cooked, remain } } = this.config

207 -

this.argv = remain

208 221

// Secrets are mostly in configs, so title is set using only the positional args

209 222

// to keep those from being leaked. We still do a best effort replaceInfo.

210 223

this.#title = ['npm'].concat(replaceInfo(remain)).join(' ').trim()

@@ -244,13 +257,7 @@ class Npm {

244 257

log.warn('using --force', 'Recommended protections disabled.')

245 258

}

246 259 247 -

// npm --versions

248 -

if (this.config.get('versions', 'cli')) {

249 -

this.argv = ['version']

250 -

this.config.set('usage', false, 'cli')

251 -

}

252 - 253 -

return { exec: true }

260 +

return { exec: true, command: commandArg, args: this.argv }

254 261

}

255 262 256 263

get isShellout () {

Original file line number Diff line number Diff line change

@@ -119,6 +119,7 @@ class Display {

119 119

#progress

120 120 121 121

// options

122 +

#command

122 123

#levelIndex

123 124

#timing

124 125

#json

@@ -159,6 +160,7 @@ class Display {

159 160

}

160 161 161 162

async load ({

163 +

command,

162 164

heading,

163 165

json,

164 166

loglevel,

@@ -168,6 +170,7 @@ class Display {

168 170

timing,

169 171

unicode,

170 172

}) {

173 +

this.#command = command

171 174

// get createSupportsColor from chalk directly if this lands

172 175

// https://github.com/chalk/chalk/pull/600

173 176

const [{ Chalk }, { createSupportsColor }] = await Promise.all([

@@ -272,10 +275,14 @@ class Display {

272 275

return

273 276

}

274 277 275 -

// HACK: if it looks like the banner and we are silent do not print it.

276 -

// There's no other way to do this right now :(

277 -

// eslint-disable-next-line max-len

278 -

if (this.#silent && args.length === 1 && args[0].startsWith('\n> ') && args[0].endsWith('\n')) {

278 +

// HACK: if it looks like the banner and we are in a state where we hide the

279 +

// banner then dont write any output. This hack can be replaced with proc-log.META

280 +

const isBanner = args.length === 1 &&

281 +

typeof args[0] === 'string' &&

282 +

args[0].startsWith('\n> ') &&

283 +

args[0].endsWith('\n')

284 +

const hideBanner = this.#silent || ['exec', 'explore'].includes(this.#command)

285 +

if (isBanner && hideBanner) {

279 286

return

280 287

}

281 288 Original file line number Diff line number Diff line change

@@ -74,7 +74,7 @@ t.test('basic usage', async t => {

74 74

// are generated in the following test

75 75

const { npm } = await loadMockNpm(t, {

76 76

mocks: {

77 -

'{LIB}/utils/cmd-list.js': { commands: [] },

77 +

'{LIB}/utils/cmd-list.js': { ...cmdList, commands: [] },

78 78

},

79 79

config: { userconfig: '/some/config/file/.npmrc' },

80 80

globals: { process: { platform: 'posix' } },

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4