From 42f087eb5af919d8f703f707b542994bca5ae970 Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Tue, 30 Sep 2025 23:55:59 +0300 Subject: [PATCH] fix: running with npx --- src/cli.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cli.ts b/src/cli.ts index e4ed167..3632214 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -1,6 +1,7 @@ #!/usr/bin/env node import { writeFile } from 'node:fs/promises'; +import { fileURLToPath } from 'node:url'; import { Octokit } from 'octokit'; import yargs from 'yargs'; import { hideBin } from 'yargs/helpers'; @@ -114,7 +115,12 @@ export async function main(): Promise { } // Only run if this is the main module (not imported for testing) -if (import.meta.url === `file://${process.argv[1]}`) { +const modulePath = fileURLToPath(import.meta.url); +const isMainModule = + process.argv[1] && + (modulePath === process.argv[1] || modulePath === fileURLToPath(`file://${process.argv[1]}`)); + +if (isMainModule) { main().then((exitCode) => { process.exit(exitCode); });