diff --git a/scripts/get-version.ts b/scripts/get-version.ts index 560e821..74cee84 100755 --- a/scripts/get-version.ts +++ b/scripts/get-version.ts @@ -4,6 +4,8 @@ * Checks for the presence of a webapp, inspects its version and prints it */ +import url from "node:url"; + import { versionFromAsar } from "./set-version.js"; async function main(): Promise { @@ -13,13 +15,16 @@ async function main(): Promise { return 0; } -if (require.main === module) { - main() - .then((ret) => { - process.exit(ret); - }) - .catch((e) => { - console.error(e); - process.exit(1); - }); +if (import.meta.url.startsWith("file:")) { + const modulePath = url.fileURLToPath(import.meta.url); + if (process.argv[1] === modulePath) { + main() + .then((ret) => { + process.exit(ret); + }) + .catch((e) => { + console.error(e); + process.exit(1); + }); + } }