File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 22// used by the ping and doctor commands
33const fetch = require ( 'npm-registry-fetch' )
44module . exports = async ( flatOptions ) => {
5- const res = await fetch ( '/-/ping?write=true' , flatOptions )
5+ const res = await fetch ( '/-/ping?write=true' , { ... flatOptions , cache : false } )
66 return res . json ( ) . catch ( ( ) => ( { } ) )
77}
Original file line number Diff line number Diff line change 11const t = require ( 'tap' )
22const { load : loadMockNpm } = require ( '../../fixtures/mock-npm.js' )
33const MockRegistry = require ( '@npmcli/mock-registry' )
4+ const cacache = require ( 'cacache' )
5+ const path = require ( 'node:path' )
46
57t . test ( 'no details' , async t => {
68 const { npm, logs, joinedOutput } = await loadMockNpm ( t )
@@ -74,3 +76,19 @@ t.test('invalid json', async t => {
7476 details : { } ,
7577 } )
7678} )
79+ t . test ( 'fail when registry is unreachable' , async t => {
80+ const { npm } = await loadMockNpm ( t , {
81+ config : { registry : 'https://ur.npmlocal.npmtest/' } ,
82+ cacheDir : { _cacache : { } } ,
83+ } )
84+ const url = `${ npm . config . get ( 'registry' ) } -/ping?write=true`
85+ const cache = path . join ( npm . cache , '_cacache' )
86+ await cacache . put ( cache ,
87+ `make-fetch-happen:request-cache:${ url } ` ,
88+ '{}' , { metadata : { url } }
89+ )
90+ t . rejects ( npm . exec ( 'ping' , [ ] ) , {
91+ code : 'ENOTFOUND' ,
92+ } ,
93+ 'throws ENOTFOUND error' )
94+ } )
You can’t perform that action at this time.
0 commit comments