Skip to content

Commit

Permalink
Make get-version.ts ESM compatible
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Telatynski <[email protected]>
  • Loading branch information
t3chguy committed Oct 31, 2024
1 parent cecea31 commit 63f3a83
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions scripts/get-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<number> {
Expand All @@ -13,13 +15,16 @@ async function main(): Promise<number> {
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);
});
}
}

0 comments on commit 63f3a83

Please sign in to comment.