Skip to content

Commit 5462a96

Browse files
committed
fix: use npm config get registry to support direct CLI invocation
Instead of only checking npm_config_registry env var (which is only set when invoked via npx/npm), now uses `npm config get registry` to read .npmrc regardless of how the CLI was started. This addresses the maintainer's feedback that the original solution did not work when DevTools CLI is called directly.
1 parent 6d91b00 commit 5462a96

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/bin/check-latest-version.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
import {execSync} from 'node:child_process';
78
import fs from 'node:fs/promises';
89
import path from 'node:path';
910
import process from 'node:process';
@@ -12,9 +13,15 @@ const cachePath = process.argv[2];
1213

1314
if (cachePath) {
1415
try {
15-
const registry =
16-
process.env.npm_config_registry?.replace(/\/$/, '') ||
17-
'https://registry.npmjs.org';
16+
let registry;
17+
try {
18+
registry = execSync('npm config get registry', {
19+
encoding: 'utf8',
20+
}).trim().replace(/\/$/, '');
21+
} catch {
22+
// npm not on PATH, fall back to default
23+
}
24+
registry ||= 'https://registry.npmjs.org';
1825
const response = await fetch(
1926
`${registry}/chrome-devtools-mcp/latest`,
2027
);

0 commit comments

Comments
 (0)