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
*/
import url from "node:url";
import { versionFromAsar } from "./set-version.js";
async function main(): Promise<number> {
@ -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);
});
}
}