Skip to content

Commit 4677f8b

Browse files
committed
wip: more test conversions
1 parent 9ab0826 commit 4677f8b

39 files changed

+1339
-1416
lines changed

lib/commands/init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Init extends BaseCommand {
6060
// to create a workspace package.json file or its folders
6161
const { content: pkg } = await PackageJson.normalize(this.npm.localPrefix).catch(err => {
6262
if (err.code === 'ENOENT') {
63-
log.warn('Missing package.json. Try with `--include-workspace-root`.')
63+
log.warn('', 'Missing package.json. Try with `--include-workspace-root`.')
6464
}
6565
throw err
6666
})

lib/commands/ping.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ class Ping extends BaseCommand {
1212
const cleanRegistry = cleanUrl(this.npm.config.get('registry'))
1313
log.notice('PING', cleanRegistry)
1414
const start = Date.now()
15-
const details = await pingUtil({ ...this.npm.flatOptions })
15+
let details = await pingUtil({ ...this.npm.flatOptions })
16+
details = { a: 1, b: 2 }
1617
const time = Date.now() - start
1718
log.notice('PONG', `${time}ms`)
1819
if (this.npm.config.get('json')) {
@@ -22,7 +23,7 @@ class Ping extends BaseCommand {
2223
details,
2324
}, null, 2))
2425
} else if (Object.keys(details).length) {
25-
log.notice('PONG', `${JSON.stringify(details, null, 2)}`)
26+
log.notice('PONG', JSON.stringify(details, null, 2))
2627
}
2728
}
2829
}

lib/npm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ class Npm {
453453
}
454454

455455
outputBuffer (arg) {
456-
this.#display.outputBuffer.push(arg)
456+
this.#display.outputBuffer(arg)
457457
}
458458

459459
flushOutput (jsonError) {

lib/utils/format.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,11 @@ const cleanControl = createCleaner((output) => {
8585
})
8686

8787
const formatWithOptions = ({ prefix = [], eol = '\n', ...options }, ...args) => {
88-
const prefixStr = prefix.filter(p => p != null).join(' ')
88+
const pre = prefix.filter(p => p != null).join(' ')
8989
return baseFormatWithOptions(options, ...args)
90-
.trim()
9190
.split(/\r?\n/)
9291
.map(cleanControl)
93-
.reduce((lines, line) =>
94-
lines += prefixStr + (prefixStr && line ? ' ' : '') + line + eol,
95-
''
96-
)
92+
.reduce((acc, l) => `${acc}${pre}${pre && l ? ' ' : ''}${l}${eol}`, '')
9793
}
9894

9995
const format = (...args) => formatWithOptions({}, ...args)

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

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ exports[`test/lib/commands/audit.js TAP audit signatures ignores optional depend
4545
audited 1 package in xxx
4646
4747
1 package has a verified registry signature
48-
4948
`
5049

5150
exports[`test/lib/commands/audit.js TAP audit signatures json output with invalid and missing signatures > must match snapshot 1`] = `
@@ -131,14 +130,12 @@ exports[`test/lib/commands/audit.js TAP audit signatures multiple registries wit
131130
audited 2 packages in xxx
132131
133132
2 packages have verified registry signatures
134-
135133
`
136134

137135
exports[`test/lib/commands/audit.js TAP audit signatures omit dev dependencies with missing signature > must match snapshot 1`] = `
138136
audited 1 package in xxx
139137
140138
1 package has a verified registry signature
141-
142139
`
143140

144141
exports[`test/lib/commands/audit.js TAP audit signatures output details about missing signatures > must match snapshot 1`] = `
@@ -157,7 +154,6 @@ audited 1 package in xxx
157154
@npmcli/[email protected] (https://verdaccio-clone.org/)
158155
159156
Someone might have tampered with this package since it was published on the registry!
160-
161157
`
162158

163159
exports[`test/lib/commands/audit.js TAP audit signatures third-party registry with keys and missing signatures errors > must match snapshot 1`] = `
@@ -172,21 +168,18 @@ exports[`test/lib/commands/audit.js TAP audit signatures third-party registry wi
172168
audited 1 package in xxx
173169
174170
1 package has a verified registry signature
175-
176171
`
177172

178173
exports[`test/lib/commands/audit.js TAP audit signatures third-party registry with sub-path (trailing slash) > must match snapshot 1`] = `
179174
audited 1 package in xxx
180175
181176
1 package has a verified registry signature
182-
183177
`
184178

185179
exports[`test/lib/commands/audit.js TAP audit signatures third-party registry with sub-path > must match snapshot 1`] = `
186180
audited 1 package in xxx
187181
188182
1 package has a verified registry signature
189-
190183
`
191184

192185
exports[`test/lib/commands/audit.js TAP audit signatures with both invalid and missing signatures > must match snapshot 1`] = `
@@ -201,14 +194,12 @@ [email protected] (https://registry.npmjs.org/)
201194
[email protected] (https://registry.npmjs.org/)
202195
203196
Someone might have tampered with this package since it was published on the registry!
204-
205197
`
206198

207199
exports[`test/lib/commands/audit.js TAP audit signatures with bundled and peer deps and no signatures > must match snapshot 1`] = `
208200
audited 1 package in xxx
209201
210202
1 package has a verified registry signature
211-
212203
`
213204

214205
exports[`test/lib/commands/audit.js TAP audit signatures with invalid attestations > must match snapshot 1`] = `
@@ -219,7 +210,6 @@ audited 1 package in xxx
219210
[email protected] (https://registry.npmjs.org/)
220211
221212
Someone might have tampered with this package since it was published on the registry!
222-
223213
`
224214

225215
exports[`test/lib/commands/audit.js TAP audit signatures with invalid signatures > must match snapshot 1`] = `
@@ -230,7 +220,6 @@ audited 1 package in xxx
230220
[email protected] (https://registry.npmjs.org/)
231221
232222
Someone might have tampered with this package since it was published on the registry!
233-
234223
`
235224

236225
exports[`test/lib/commands/audit.js TAP audit signatures with invalid signtaures and color output enabled > must match snapshot 1`] = `
@@ -241,14 +230,12 @@ audited 1 package in xxx
241230
[[email protected] (https://registry.npmjs.org/)
242231
243232
Someone might have tampered with this package since it was published on the registry!
244-
245233
`
246234

247235
exports[`test/lib/commands/audit.js TAP audit signatures with key fallback to legacy API > must match snapshot 1`] = `
248236
audited 1 package in xxx
249237
250238
1 package has a verified registry signature
251-
252239
`
253240

254241
exports[`test/lib/commands/audit.js TAP audit signatures with keys but missing signature > must match snapshot 1`] = `
@@ -268,7 +255,6 @@ [email protected] (https://registry.npmjs.org/)
268255
[email protected] (https://registry.npmjs.org/)
269256
270257
Someone might have tampered with these packages since they were published on the registry!
271-
272258
`
273259

274260
exports[`test/lib/commands/audit.js TAP audit signatures with multiple invalid signatures > must match snapshot 1`] = `
@@ -280,7 +266,6 @@ [email protected] (https://registry.npmjs.org/)
280266
[email protected] (https://registry.npmjs.org/)
281267
282268
Someone might have tampered with these packages since they were published on the registry!
283-
284269
`
285270

286271
exports[`test/lib/commands/audit.js TAP audit signatures with multiple missing signatures > must match snapshot 1`] = `
@@ -302,7 +287,6 @@ audited 3 packages in xxx
302287
[email protected] (https://registry.npmjs.org/)
303288
304289
Someone might have tampered with this package since it was published on the registry!
305-
306290
`
307291

308292
exports[`test/lib/commands/audit.js TAP audit signatures with valid and missing signatures > must match snapshot 1`] = `
@@ -321,35 +305,30 @@ audited 1 package in xxx
321305
1 package has a verified registry signature
322306
323307
1 package has a verified attestation
324-
325308
`
326309

327310
exports[`test/lib/commands/audit.js TAP audit signatures with valid signatures > must match snapshot 1`] = `
328311
audited 1 package in xxx
329312
330313
1 package has a verified registry signature
331-
332314
`
333315

334316
exports[`test/lib/commands/audit.js TAP audit signatures with valid signatures using alias > must match snapshot 1`] = `
335317
audited 1 package in xxx
336318
337319
1 package has a verified registry signature
338-
339320
`
340321

341322
exports[`test/lib/commands/audit.js TAP audit signatures workspaces verifies registry deps and ignores local workspace deps > must match snapshot 1`] = `
342323
audited 3 packages in xxx
343324
344325
3 packages have verified registry signatures
345-
346326
`
347327

348328
exports[`test/lib/commands/audit.js TAP audit signatures workspaces verifies registry deps when filtering by workspace name > must match snapshot 1`] = `
349329
audited 2 packages in xxx
350330
351331
2 packages have verified registry signatures
352-
353332
`
354333

355334
exports[`test/lib/commands/audit.js TAP fallback audit > must match snapshot 1`] = `

0 commit comments

Comments
 (0)