Chrome DevTools for coding agents
fix: respect user's npm registry configuration in update check (#2038)
Serhii Zghama83a299fc95c6
diff --git a/src/bin/check-latest-version.ts b/src/bin/check-latest-version.tsindex eb45674d..e3ef2c80 100644--- a/src/bin/check-latest-version.ts+++ b/src/bin/check-latest-version.ts@@ -4,17 +4,40 @@* SPDX-License-Identifier: Apache-2.0*/+import {execSync} from 'node:child_process';import fs from 'node:fs/promises';import path from 'node:path';import process from 'node:process';+const DEFAULT_REGISTRY = 'https://registry.npmjs.org';++function getRegistry(): string {+ // Use the user's configured npm registry so update checks work behind+ // corporate proxies and private registries. `npm config get registry`+ // honors .npmrc files at every scope and respects npm_config_registry,+ // so it covers direct CLI invocations as well as `npx` / `npm run`.+ try {+ const registry = execSync('npm config get registry', {+ encoding: 'utf8',+ stdio: ['ignore', 'pipe', 'ignore'],+ timeout: 5000,+ })+ .trim()+ .replace(/\/$/, '');+ if (registry && registry !== 'undefined' && /^https?:\/\//.test(registry)) {+ return registry;+ }+ } catch {+ // npm not on PATH or other errors, fall back to default.+ }+ return DEFAULT_REGISTRY;+}+const cachePath = process.argv[2];if (cachePath) {try {- const response = await fetch(- 'https://registry.npmjs.org/chrome-devtools-mcp/latest',- );+ const response = await fetch(`${getRegistry()}/chrome-devtools-mcp/latest`);const data = response.ok ? await response.json() : null;if (