From 2472da20fc803dfde13fc31aa83edd8c12367fec Mon Sep 17 00:00:00 2001 From: Bart Mesuere Date: Wed, 7 Aug 2024 16:39:31 +0200 Subject: [PATCH] fix relative file paths --- lib/commands/base_command.ts | 6 +++++- lib/commands/unipept/unipept_subcommand.ts | 6 +++++- package.json | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/commands/base_command.ts b/lib/commands/base_command.ts index efa87e6a..c0480c17 100644 --- a/lib/commands/base_command.ts +++ b/lib/commands/base_command.ts @@ -13,7 +13,11 @@ export abstract class BaseCommand { version: string; constructor(options?: { exitOverride?: boolean, suppressOutput?: boolean }) { - this.version = JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8")).version; + let p = ""; + if (import.meta.url.includes("/dist/")) { + p = "../"; + } + this.version = JSON.parse(readFileSync(new URL(p + "../../package.json", import.meta.url), "utf8")).version; this.program = this.create(options); } diff --git a/lib/commands/unipept/unipept_subcommand.ts b/lib/commands/unipept/unipept_subcommand.ts index 47f6d210..f2d73324 100644 --- a/lib/commands/unipept/unipept_subcommand.ts +++ b/lib/commands/unipept/unipept_subcommand.ts @@ -29,7 +29,11 @@ export abstract class UnipeptSubcommand { constructor(name: string) { this.name = name; - const version = JSON.parse(readFileSync(new URL("../../../package.json", import.meta.url), "utf8")).version; + let p = ""; + if (import.meta.url.includes("/dist/")) { + p = "../"; + } + const version = JSON.parse(readFileSync(new URL(p + "../../../package.json", import.meta.url), "utf8")).version; this.user_agent = `unipept-cli/${version}`; this.command = this.create(name); this.fasta = false; diff --git a/package.json b/package.json index befa17c3..e985f632 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "unipept-cli", - "version": "4.0.0-1", + "version": "4.0.0-2", "description": "Command line interface to the Unipept web services", "repository": "git@github.com:unipept/unipept-cli.git", "author": "Bart Mesuere ",