Skip to content

Commit cc01fbf

Browse files
committed
fix: resolve symlinks in CLI entry check for npx compatibility
1 parent 1f8ce1a commit cc01fbf

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/cli.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ async function runGenerate(args: CliArgs): Promise<void> {
189189
}
190190

191191
// Only run when executed directly (not when imported by tests)
192-
const isMain = process.argv[1] && fileURLToPath(import.meta.url) === path.resolve(process.argv[1]);
193-
if (isMain) {
192+
const thisFile = fs.realpathSync(fileURLToPath(import.meta.url));
193+
const entryFile = process.argv[1] ? fs.realpathSync(path.resolve(process.argv[1])) : '';
194+
if (thisFile === entryFile) {
194195
createProgram().parseAsync();
195196
}

0 commit comments

Comments
 (0)