diff --git a/src/hooks/diagnostics.ts b/src/hooks/diagnostics.ts index 7ec5b9c1..ed42038d 100644 --- a/src/hooks/diagnostics.ts +++ b/src/hooks/diagnostics.ts @@ -10,25 +10,22 @@ import { NpmModule } from '../shared/npmCommand.js'; type HookFunction = (options: { doctor: SfDoctor }) => Promise<[void]>; export const hook: HookFunction = (options) => Promise.all([registryCheck(options)]); -// eslint-disable-next-line @typescript-eslint/require-await const registryCheck = async (options: { doctor: SfDoctor }): Promise => { // find npm install const npm = new NpmModule(''); - const config = npm.run('config get registry').stdout.trim(); - const customRegistry = - process.env.npm_config_registry ?? process.env.NPM_CONFIG_REGISTRY ?? config !== 'https://registry.npmjs.org/' - ? config - : undefined; - // eslint-disable-next-line @typescript-eslint/no-floating-promises - [ - // npm and yarn registries - 'https://registry.npmjs.org', - 'https://registry.yarnpkg.com', - customRegistry, - ] - // incase customRegistry is undefined, prevent printing an extra line - .filter((u) => u) - .map(async (url) => { + + await Promise.all( + [ + ...new Set([ + // npm and yarn registries + 'https://registry.npmjs.org', + 'https://registry.yarnpkg.com', + process.env.npm_config_registry ?? + process.env.NPM_CONFIG_REGISTRY ?? + npm.run('config get registry').stdout.trim() ?? + 'https://registry.npmjs.org', + ]), + ].map(async (url) => { try { const results = npm.ping(url); @@ -44,5 +41,6 @@ const registryCheck = async (options: { doctor: SfDoctor }): Promise => { `Cannot reach ${url} - potential network configuration error, check proxies, firewalls, environment variables` ); } - }); + }) + ); };