From 7e519af89f2c06964e5c2c174a058d79d32c94c9 Mon Sep 17 00:00:00 2001 From: Andy Sturrock <8336404+andysturrock@users.noreply.github.com> Date: Wed, 16 Aug 2023 07:53:35 +0100 Subject: [PATCH] Fix package.json location (#456) (#458) From https://github.com/ohmjs/ohm/issues/456 Parse ohm's package.json file to obtain the version. cli.js was parsing the package.json in the current directory to obtain the package version. It now parses its own package.json file, not the one from the project that is using ohm. Co-authored-by: Andy Sturrock --- packages/cli/src/cli.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/cli.js b/packages/cli/src/cli.js index 19b6c6ec..5eae5262 100644 --- a/packages/cli/src/cli.js +++ b/packages/cli/src/cli.js @@ -2,8 +2,9 @@ import {Command} from 'commander'; import fs from 'fs'; import commands from './commands/index.js'; +import url from 'url'; -const {version} = JSON.parse(fs.readFileSync('./package.json')); +const {version} = JSON.parse(fs.readFileSync(new url.URL('../package.json', import.meta.url))); export function ohmCli(userArgs, optsForTesting = {}) { const program = new Command();