From c8f992cb8678d70e7d5a544bdaf0f048a1e451c6 Mon Sep 17 00:00:00 2001 From: silverwind Date: Tue, 20 Apr 2021 23:26:27 +0200 Subject: [PATCH] fix package.json loading --- updates.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/updates.js b/updates.js index 612f2d6..bf04052 100755 --- a/updates.js +++ b/updates.js @@ -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); }