From 4b301d3064cb535a32657e88723749f460a5654c Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Tue, 2 Jan 2024 20:34:41 -0500 Subject: [PATCH] Set version from `package.json`. --- CHANGELOG.md | 1 + bin/jsonld.js | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 245886a..74f8c04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 2.0.0 - 2024-01-xx ## Changed +- Set version from `package.json`. - **BREAKING**: Update dependencies. - `commander` requires Node.js >= 16. diff --git a/bin/jsonld.js b/bin/jsonld.js index f49a443..d6196c4 100755 --- a/bin/jsonld.js +++ b/bin/jsonld.js @@ -15,7 +15,14 @@ import {jsonldRequest} from 'jsonld-request'; import path from 'node:path'; import {program} from 'commander'; -program.version('1.0.0'); +import {fileURLToPath} from 'node:url'; +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + +import {readFileSync} from 'node:fs'; +const version = + JSON.parse(readFileSync(path.join(__dirname, '..', 'package.json'))).version; + +program.version(version); // all allowed modes for jsonld-request const ALLOW_ALL = ['stdin', 'file', 'http', 'https'];