fix package.json loading

This commit is contained in:
silverwind 2021-04-20 23:26:27 +02:00
parent dde736edee
commit c8f992cb86
Signed by untrusted user: silverwind
GPG Key ID: 2E62B41C93869443

@ -15,7 +15,6 @@ import {fromUrl} from "hosted-git-info";
import {join, dirname} from "path";
import {lstatSync, readFileSync, truncateSync, writeFileSync, accessSync} from "fs";
import {platform} from "os";
import {fileURLToPath} from "url";
const fetch = fetchEnhanced(nodeFetch);
@ -173,9 +172,8 @@ if (args.help) {
}
if (args.version) {
const dir = dirname(fileURLToPath(import.meta.url));
const pkgJson = join(dir, "./package.json"); // resolve acts weirdly here in compiled file
const {version} = JSON.parse(readFileSync(pkgJson, "utf8"));
const path = new URL("./package.json", import.meta.url);
const {version} = JSON.parse(readFileSync(path, "utf8"));
console.info(version);
exit(0);
}