From dce3b0896ba81b2109fea42ab32edd8a3193324c Mon Sep 17 00:00:00 2001 From: Gar Date: Mon, 6 Nov 2023 08:46:48 -0800 Subject: [PATCH] fix: properly catch missing url opener error (#6951) --- lib/utils/open-url.js | 2 +- test/lib/utils/open-url.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/utils/open-url.js b/lib/utils/open-url.js index f882d0c9d3934..77bb1d03d8e16 100644 --- a/lib/utils/open-url.js +++ b/lib/utils/open-url.js @@ -39,7 +39,7 @@ const open = async (npm, url, errMsg, isFile) => { const command = browser === true ? null : browser await promiseSpawn.open(url, { command }) .catch((err) => { - if (err.code !== 'ENOENT') { + if (err.code !== 127) { throw err } diff --git a/test/lib/utils/open-url.js b/test/lib/utils/open-url.js index 0ce1b57aa5f9f..dab7b41b92f1f 100644 --- a/test/lib/utils/open-url.js +++ b/test/lib/utils/open-url.js @@ -124,7 +124,7 @@ t.test('prints where to go when given browser does not exist', async t => { const { openerUrl, openerOpts, joinedOutput } = await mockOpenUrl(t, ['https://www.npmjs.com', 'npm home'], { - openerResult: Object.assign(new Error('failed'), { code: 'ENOENT' }), + openerResult: Object.assign(new Error('failed'), { code: 127 }), } )