@npmcli/config 8.2.2 → 8.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/definitions/definitions.js +2 -2
- package/lib/index.js +6 -24
- package/package.json +2 -2
|
@@ -7,10 +7,10 @@ const { join } = require('node:path')
|
|
|
7
7
|
const isWindows = process.platform === 'win32'
|
|
8
8
|
|
|
9
9
|
// used by cafile flattening to flatOptions.ca
|
|
10
|
-
const
|
|
10
|
+
const { readFileSync } = require('fs')
|
|
11
11
|
const maybeReadFile = file => {
|
|
12
12
|
try {
|
|
13
|
-
return
|
|
13
|
+
return readFileSync(file, 'utf8')
|
|
14
14
|
} catch (er) {
|
|
15
15
|
if (er.code !== 'ENOENT') {
|
|
16
16
|
throw er
|
package/lib/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const { walkUp } = require('walk-up-path')
|
|
3
3
|
const ini = require('ini')
|
|
4
4
|
const nopt = require('nopt')
|
|
5
|
-
const log = require('proc-log')
|
|
5
|
+
const { log, time } = require('proc-log')
|
|
6
6
|
|
|
7
7
|
const { resolve, dirname, join } = require('node:path')
|
|
8
8
|
const { homedir } = require('node:os')
|
|
@@ -201,7 +201,7 @@ class Config {
|
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
// create the object for flat options passed to deps
|
|
204
|
-
|
|
204
|
+
const timeEnd = time.start('config:load:flatten')
|
|
205
205
|
this.#flatOptions = {}
|
|
206
206
|
// walk from least priority to highest
|
|
207
207
|
for (const { data } of this.data.values()) {
|
|
@@ -209,7 +209,7 @@ class Config {
|
|
|
209
209
|
}
|
|
210
210
|
this.#flatOptions.nodeBin = this.execPath
|
|
211
211
|
this.#flatOptions.npmBin = this.npmBin
|
|
212
|
-
|
|
212
|
+
timeEnd()
|
|
213
213
|
|
|
214
214
|
return this.#flatOptions
|
|
215
215
|
}
|
|
@@ -233,37 +233,24 @@ class Config {
|
|
|
233
233
|
throw new Error('attempting to load npm config multiple times')
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
-
process.emit('time', 'config:load')
|
|
237
236
|
// first load the defaults, which sets the global prefix
|
|
238
|
-
process.emit('time', 'config:load:defaults')
|
|
239
237
|
this.loadDefaults()
|
|
240
|
-
process.emit('timeEnd', 'config:load:defaults')
|
|
241
238
|
|
|
242
239
|
// next load the builtin config, as this sets new effective defaults
|
|
243
|
-
process.emit('time', 'config:load:builtin')
|
|
244
240
|
await this.loadBuiltinConfig()
|
|
245
|
-
process.emit('timeEnd', 'config:load:builtin')
|
|
246
241
|
|
|
247
242
|
// cli and env are not async, and can set the prefix, relevant to project
|
|
248
|
-
process.emit('time', 'config:load:cli')
|
|
249
243
|
this.loadCLI()
|
|
250
|
-
process.emit('timeEnd', 'config:load:cli')
|
|
251
|
-
process.emit('time', 'config:load:env')
|
|
252
244
|
this.loadEnv()
|
|
253
|
-
process.emit('timeEnd', 'config:load:env')
|
|
254
245
|
|
|
255
246
|
// next project config, which can affect userconfig location
|
|
256
|
-
process.emit('time', 'config:load:project')
|
|
257
247
|
await this.loadProjectConfig()
|
|
258
|
-
|
|
248
|
+
|
|
259
249
|
// then user config, which can affect globalconfig location
|
|
260
|
-
process.emit('time', 'config:load:user')
|
|
261
250
|
await this.loadUserConfig()
|
|
262
|
-
|
|
251
|
+
|
|
263
252
|
// last but not least, global config file
|
|
264
|
-
process.emit('time', 'config:load:global')
|
|
265
253
|
await this.loadGlobalConfig()
|
|
266
|
-
process.emit('timeEnd', 'config:load:global')
|
|
267
254
|
|
|
268
255
|
// set this before calling setEnvs, so that we don't have to share
|
|
269
256
|
// private attributes, as that module also does a bunch of get operations
|
|
@@ -272,11 +259,7 @@ class Config {
|
|
|
272
259
|
// set proper globalPrefix now that everything is loaded
|
|
273
260
|
this.globalPrefix = this.get('prefix')
|
|
274
261
|
|
|
275
|
-
process.emit('time', 'config:load:setEnvs')
|
|
276
262
|
this.setEnvs()
|
|
277
|
-
process.emit('timeEnd', 'config:load:setEnvs')
|
|
278
|
-
|
|
279
|
-
process.emit('timeEnd', 'config:load')
|
|
280
263
|
}
|
|
281
264
|
|
|
282
265
|
loadDefaults () {
|
|
@@ -601,8 +584,8 @@ class Config {
|
|
|
601
584
|
}
|
|
602
585
|
|
|
603
586
|
async #loadFile (file, type) {
|
|
604
|
-
process.emit('time', 'config:load:file:' + file)
|
|
605
587
|
// only catch the error from readFile, not from the loadObject call
|
|
588
|
+
log.silly(`config:load:file:${file}`)
|
|
606
589
|
await readFile(file, 'utf8').then(
|
|
607
590
|
data => {
|
|
608
591
|
const parsedConfig = ini.parse(data)
|
|
@@ -615,7 +598,6 @@ class Config {
|
|
|
615
598
|
},
|
|
616
599
|
er => this.#loadObject(null, type, file, er)
|
|
617
600
|
)
|
|
618
|
-
process.emit('timeEnd', 'config:load:file:' + file)
|
|
619
601
|
}
|
|
620
602
|
|
|
621
603
|
loadBuiltinConfig () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@npmcli/config",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.3.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"bin/",
|
|
6
6
|
"lib/"
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"ci-info": "^4.0.0",
|
|
41
41
|
"ini": "^4.1.2",
|
|
42
42
|
"nopt": "^7.0.0",
|
|
43
|
-
"proc-log": "^
|
|
43
|
+
"proc-log": "^4.2.0",
|
|
44
44
|
"read-package-json-fast": "^3.0.2",
|
|
45
45
|
"semver": "^7.3.5",
|
|
46
46
|
"walk-up-path": "^3.0.1"
|