Skip to content

Commit 41c4667

Browse files
cameroncookeclaude
andcommitted
fix(build): Guard import.meta usage for CJS Smithery builds
Smithery capability scanning runs a CJS bundle in CI. Accessing fileURLToPath(importMetaUrl) without a guard can throw when import.meta is present but does not include a usable url, which broke the build-and-test job. Guard the import-meta candidate so package-root discovery still works via process.cwd() and argv fallbacks in CJS environments. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 8365d56 commit 41c4667

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/core/resource-root.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ function findPackageRootFrom(startDir: string): string | null {
2121

2222
export function getPackageRoot(): string {
2323
const candidates: string[] = [];
24-
candidates.push(path.dirname(fileURLToPath(import.meta.url)));
24+
const importMetaUrl = typeof import.meta.url === 'string' ? import.meta.url : null;
25+
if (importMetaUrl) {
26+
candidates.push(path.dirname(fileURLToPath(importMetaUrl)));
27+
}
2528
candidates.push(process.cwd());
2629
const entry = process.argv[1];
2730
if (entry) {

0 commit comments

Comments
 (0)