From c1255e16c781ba8b3669affc915948afad6b99d4 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Thu, 7 Jan 2021 12:55:59 -0600 Subject: [PATCH] Fix .version lookup (close #28) --- bin/hyp.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/hyp.js b/bin/hyp.js index 2a08d9d..fe090f5 100755 --- a/bin/hyp.js +++ b/bin/hyp.js @@ -2,6 +2,8 @@ import subcommand from 'subcommand' import fs from 'fs' +import path from 'path' +import { fileURLToPath } from 'url' import * as hyper from '../lib/hyper/index.js' @@ -74,7 +76,7 @@ match(argv) // error output when no/invalid command is given function none (args) { if (args.version) { - const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8')) + const packageJson = JSON.parse(fs.readFileSync(path.join(fileURLToPath(import.meta.url), '../../package.json'), 'utf8')) console.log(packageJson.version) process.exit(0) }