Skip to content

Commit ba6d9a8

Browse files
committed
fix: add first param titles to logs where missing
1 parent badeac2 commit ba6d9a8

File tree

6 files changed

+28
-22
lines changed

6 files changed

+28
-22
lines changed

lib/commands/audit.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class Audit extends ArboristWorkspaceCmd {
9090
)
9191
}
9292

93-
log.verbose('loading installed dependencies')
93+
log.verbose('audit', 'loading installed dependencies')
9494
const Arborist = require('@npmcli/arborist')
9595
const opts = {
9696
...this.npm.flatOptions,

lib/commands/cache.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class Cache extends BaseCommand {
132132
try {
133133
entry = await cacache.get(cachePath, key)
134134
} catch (err) {
135-
log.warn(`Not Found: ${key}`)
135+
log.warn('cache', `Not Found: ${key}`)
136136
break
137137
}
138138
output.standard(`Deleted: ${key}`)

tap-snapshots/test/lib/commands/shrinkwrap.js.test.cjs

+11-11
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ exports[`test/lib/commands/shrinkwrap.js TAP with hidden lockfile ancient upgrad
4949
"created a lockfile as npm-shrinkwrap.json with version 3"
5050
],
5151
"warn": [
52-
"Converting lock file (npm-shrinkwrap.json) from v1 -> v3"
52+
"shrinkwrap Converting lock file (npm-shrinkwrap.json) from v1 -> v3"
5353
]
5454
}
5555
`
@@ -98,7 +98,7 @@ exports[`test/lib/commands/shrinkwrap.js TAP with hidden lockfile existing downg
9898
"created a lockfile as npm-shrinkwrap.json with version 1"
9999
],
100100
"warn": [
101-
"Converting lock file (npm-shrinkwrap.json) from v2 -> v1"
101+
"shrinkwrap Converting lock file (npm-shrinkwrap.json) from v2 -> v1"
102102
]
103103
}
104104
`
@@ -125,7 +125,7 @@ exports[`test/lib/commands/shrinkwrap.js TAP with hidden lockfile existing upgra
125125
"created a lockfile as npm-shrinkwrap.json with version 3"
126126
],
127127
"warn": [
128-
"Converting lock file (npm-shrinkwrap.json) from v2 -> v3"
128+
"shrinkwrap Converting lock file (npm-shrinkwrap.json) from v2 -> v3"
129129
]
130130
}
131131
`
@@ -188,7 +188,7 @@ exports[`test/lib/commands/shrinkwrap.js TAP with npm-shrinkwrap.json ancient >
188188
"npm-shrinkwrap.json updated to version 3"
189189
],
190190
"warn": [
191-
"Converting lock file (npm-shrinkwrap.json) from v1 -> v3"
191+
"shrinkwrap Converting lock file (npm-shrinkwrap.json) from v1 -> v3"
192192
]
193193
}
194194
`
@@ -217,7 +217,7 @@ exports[`test/lib/commands/shrinkwrap.js TAP with npm-shrinkwrap.json ancient up
217217
"npm-shrinkwrap.json updated to version 3"
218218
],
219219
"warn": [
220-
"Converting lock file (npm-shrinkwrap.json) from v1 -> v3"
220+
"shrinkwrap Converting lock file (npm-shrinkwrap.json) from v1 -> v3"
221221
]
222222
}
223223
`
@@ -266,7 +266,7 @@ exports[`test/lib/commands/shrinkwrap.js TAP with npm-shrinkwrap.json existing d
266266
"npm-shrinkwrap.json updated to version 1"
267267
],
268268
"warn": [
269-
"Converting lock file (npm-shrinkwrap.json) from v2 -> v1"
269+
"shrinkwrap Converting lock file (npm-shrinkwrap.json) from v2 -> v1"
270270
]
271271
}
272272
`
@@ -295,7 +295,7 @@ exports[`test/lib/commands/shrinkwrap.js TAP with npm-shrinkwrap.json existing u
295295
"npm-shrinkwrap.json updated to version 3"
296296
],
297297
"warn": [
298-
"Converting lock file (npm-shrinkwrap.json) from v2 -> v3"
298+
"shrinkwrap Converting lock file (npm-shrinkwrap.json) from v2 -> v3"
299299
]
300300
}
301301
`
@@ -322,7 +322,7 @@ exports[`test/lib/commands/shrinkwrap.js TAP with package-lock.json ancient > mu
322322
"package-lock.json has been renamed to npm-shrinkwrap.json and updated to version 3"
323323
],
324324
"warn": [
325-
"Converting lock file (npm-shrinkwrap.json) from v1 -> v3"
325+
"shrinkwrap Converting lock file (npm-shrinkwrap.json) from v1 -> v3"
326326
]
327327
}
328328
`
@@ -351,7 +351,7 @@ exports[`test/lib/commands/shrinkwrap.js TAP with package-lock.json ancient upgr
351351
"package-lock.json has been renamed to npm-shrinkwrap.json and updated to version 3"
352352
],
353353
"warn": [
354-
"Converting lock file (npm-shrinkwrap.json) from v1 -> v3"
354+
"shrinkwrap Converting lock file (npm-shrinkwrap.json) from v1 -> v3"
355355
]
356356
}
357357
`
@@ -400,7 +400,7 @@ exports[`test/lib/commands/shrinkwrap.js TAP with package-lock.json existing dow
400400
"package-lock.json has been renamed to npm-shrinkwrap.json and updated to version 1"
401401
],
402402
"warn": [
403-
"Converting lock file (npm-shrinkwrap.json) from v2 -> v1"
403+
"shrinkwrap Converting lock file (npm-shrinkwrap.json) from v2 -> v1"
404404
]
405405
}
406406
`
@@ -429,7 +429,7 @@ exports[`test/lib/commands/shrinkwrap.js TAP with package-lock.json existing upg
429429
"package-lock.json has been renamed to npm-shrinkwrap.json and updated to version 3"
430430
],
431431
"warn": [
432-
"Converting lock file (npm-shrinkwrap.json) from v2 -> v3"
432+
"shrinkwrap Converting lock file (npm-shrinkwrap.json) from v2 -> v3"
433433
]
434434
}
435435
`

workspaces/arborist/lib/shrinkwrap.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,8 @@ class Shrinkwrap {
11531153
&& this.originalLockfileVersion !== this.lockfileVersion
11541154
) {
11551155
log.warn(
1156-
`Converting lock file (${relative(process.cwd(), this.filename)}) from v${this.originalLockfileVersion} -> v${this.lockfileVersion}`
1156+
'shrinkwrap',
1157+
`Converting lock file (${relative(process.cwd(), this.filename)}) from v${this.originalLockfileVersion} -> v${this.lockfileVersion}`
11571158
)
11581159
}
11591160

workspaces/config/lib/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ class Config {
585585

586586
async #loadFile (file, type) {
587587
// only catch the error from readFile, not from the loadObject call
588-
log.silly(`config:load:file:${file}`)
588+
log.silly('config', `load:file:${file}`)
589589
await readFile(file, 'utf8').then(
590590
data => {
591591
const parsedConfig = ini.parse(data)
@@ -684,15 +684,15 @@ class Config {
684684
if (w === this.localPrefix) {
685685
// see if there's a .npmrc file in the workspace, if so log a warning
686686
if (await fileExists(this.localPrefix, '.npmrc')) {
687-
log.warn(`ignoring workspace config at ${this.localPrefix}/.npmrc`)
687+
log.warn('config', `ignoring workspace config at ${this.localPrefix}/.npmrc`)
688688
}
689689

690690
// set the workspace in the default layer, which allows it to be overridden easily
691691
const { data } = this.data.get('default')
692692
data.workspace = [this.localPrefix]
693693
this.localPrefix = p
694694
this.localPackage = hasPackageJson
695-
log.info(`found workspace root at ${this.localPrefix}`)
695+
log.info('config', `found workspace root at ${this.localPrefix}`)
696696
// we found a root, so we return now
697697
return
698698
}

workspaces/config/test/index.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,8 @@ t.test('workspaces', async (t) => {
11851185
t.same(config.get('workspace'), [join(path, 'workspaces', 'one')], 'set the workspace')
11861186
const info = logs.filter(l => l[0] === 'info')
11871187
t.equal(info.length, 1, 'got one log message')
1188-
t.match(info[0], ['info', /^found workspace root at/], 'logged info about workspace root')
1188+
t.match(info[0],
1189+
['info', 'config', /^found workspace root at/], 'logged info about workspace root')
11891190
})
11901191

11911192
t.test('finds other workspace parent', async (t) => {
@@ -1207,7 +1208,8 @@ t.test('workspaces', async (t) => {
12071208
t.same(config.get('workspace'), ['../two'], 'kept the specified workspace')
12081209
const info = logs.filter(l => l[0] === 'info')
12091210
t.equal(info.length, 1, 'got one log message')
1210-
t.match(info[0], ['info', /^found workspace root at/], 'logged info about workspace root')
1211+
t.match(info[0],
1212+
['info', 'config', /^found workspace root at/], 'logged info about workspace root')
12111213
})
12121214

12131215
t.test('warns when workspace has .npmrc', async (t) => {
@@ -1229,8 +1231,10 @@ t.test('workspaces', async (t) => {
12291231
t.same(config.get('workspace'), [join(path, 'workspaces', 'three')], 'kept the workspace')
12301232
const filtered = logs.filter(l => l[0] === 'info' || l[0] === 'warn')
12311233
t.equal(filtered.length, 2, 'got two log messages')
1232-
t.match(filtered[0], ['warn', /^ignoring workspace config/], 'warned about ignored config')
1233-
t.match(filtered[1], ['info', /^found workspace root at/], 'logged info about workspace root')
1234+
t.match(filtered[0],
1235+
['warn', 'config', /^ignoring workspace config/], 'warned about ignored config')
1236+
t.match(filtered[1],
1237+
['info', 'config', /^found workspace root at/], 'logged info about workspace root')
12341238
})
12351239

12361240
t.test('prefix skips auto detect', async (t) => {
@@ -1364,7 +1368,8 @@ t.test('workspaces', async (t) => {
13641368
t.same(config.get('workspace'), [join(path, 'workspaces', 'one')], 'set the workspace')
13651369
const filtered = logs.filter(l => l[0] !== 'silly')
13661370
t.equal(filtered.length, 1, 'got one log message')
1367-
t.match(filtered[0], ['info', /^found workspace root at/], 'logged info about workspace root')
1371+
t.match(filtered[0],
1372+
['info', 'config', /^found workspace root at/], 'logged info about workspace root')
13681373
})
13691374
})
13701375

0 commit comments

Comments
 (0)