Skip to content

Commit 1c182e1

Browse files
wraithgarruyadorno
authored andcommitted
fix(doctor): don't retry ping
1 parent 0da5918 commit 1c182e1

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-1
lines changed

lib/commands/doctor.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class Doctor extends BaseCommand {
142142
const tracker = log.newItem('checkPing', 1)
143143
tracker.info('checkPing', 'Pinging registry')
144144
try {
145-
await ping(this.npm.flatOptions)
145+
await ping({ ...this.npm.flatOptions, retry: false })
146146
return ''
147147
} catch (er) {
148148
if (/^E\d{3}$/.test(er.code || '')) {

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

+58
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,64 @@ Object {
121121
}
122122
`
123123

124+
exports[`test/lib/commands/doctor.js TAP bad proxy > logs 1`] = `
125+
Object {
126+
"error": Array [],
127+
"info": Array [
128+
Array [
129+
"Running checkup",
130+
],
131+
Array [
132+
"checkPing",
133+
"Pinging registry",
134+
],
135+
Array [
136+
"getLatestNpmVersion",
137+
"Getting npm package information",
138+
],
139+
Array [
140+
"getLatestNodejsVersion",
141+
"Getting Node.js release information",
142+
],
143+
Array [
144+
"getGitPath",
145+
"Finding git in your PATH",
146+
],
147+
Array [
148+
"verifyCachedFiles",
149+
"Verifying the npm cache",
150+
],
151+
Array [
152+
"verifyCachedFiles",
153+
String(
154+
Verification complete. Stats: {
155+
"badContentCount": 0,
156+
"reclaimedCount": 0,
157+
"missingContent": 0,
158+
"verifiedContent": 0
159+
}
160+
),
161+
],
162+
],
163+
"warn": Array [],
164+
}
165+
`
166+
167+
exports[`test/lib/commands/doctor.js TAP bad proxy > output 1`] = `
168+
Check Value Recommendation/Notes
169+
npm ping not ok unsupported proxy protocol: 'ssh:'
170+
npm -v not ok Error: unsupported proxy protocol: 'ssh:'
171+
node -v not ok Error: unsupported proxy protocol: 'ssh:'
172+
npm config get registry ok using default registry (https://registry.npmjs.org/)
173+
which git ok /path/to/git
174+
Perms check on cached files ok
175+
Perms check on local node_modules ok
176+
Perms check on global node_modules ok
177+
Perms check on local bin folder ok
178+
Perms check on global bin folder ok
179+
Verify cache contents ok verified 0 tarballs
180+
`
181+
124182
exports[`test/lib/commands/doctor.js TAP cacache badContent > corrupted cache content 1`] = `
125183
Check Value Recommendation/Notes
126184
npm ping ok

test/lib/commands/doctor.js

+14
Original file line numberDiff line numberDiff line change
@@ -461,3 +461,17 @@ t.test('cacache missingContent', async t => {
461461
t.matchSnapshot(joinedOutput(), 'missing content')
462462
t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs')
463463
})
464+
465+
t.test('bad proxy', async t => {
466+
const { joinedOutput, logs, npm } = await loadMockNpm(t, {
467+
mocks,
468+
config: {
469+
proxy: 'ssh://npmjs.org'
470+
},
471+
...dirs,
472+
})
473+
await t.rejects(npm.exec('doctor', []))
474+
t.matchSnapshot(joinedOutput(), 'output')
475+
t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs')
476+
})
477+

0 commit comments

Comments
 (0)