Make get-version.ts ESM compatible

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2024-10-31 09:07:58 +00:00
parent cecea312c6
commit 63f3a834cc
No known key found for this signature in database
GPG Key ID: A2B008A5F49F5D0D

View File

@ -4,6 +4,8 @@
* Checks for the presence of a webapp, inspects its version and prints it * Checks for the presence of a webapp, inspects its version and prints it
*/ */
import url from "node:url";
import { versionFromAsar } from "./set-version.js"; import { versionFromAsar } from "./set-version.js";
async function main(): Promise<number> { async function main(): Promise<number> {
@ -13,7 +15,9 @@ async function main(): Promise<number> {
return 0; return 0;
} }
if (require.main === module) { if (import.meta.url.startsWith("file:")) {
const modulePath = url.fileURLToPath(import.meta.url);
if (process.argv[1] === modulePath) {
main() main()
.then((ret) => { .then((ret) => {
process.exit(ret); process.exit(ret);
@ -22,4 +26,5 @@ if (require.main === module) {
console.error(e); console.error(e);
process.exit(1); process.exit(1);
}); });
}
} }