From 4bf287b2242e6ea2cf98c9e65659599f62fdef4b Mon Sep 17 00:00:00 2001 From: Brad Marsden Date: Thu, 13 Jun 2024 23:14:42 +0100 Subject: [PATCH] fix: update version import to be consistent with WebTorrent (#310) * fix: update version to use require to be more consistent with WebTorrent * fix: linting --- bin/cmd.js | 2 +- version.cjs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 version.cjs diff --git a/bin/cmd.js b/bin/cmd.js index 47be647..fb1ef52 100755 --- a/bin/cmd.js +++ b/bin/cmd.js @@ -20,7 +20,7 @@ import Yargs from 'yargs' import { hideBin } from 'yargs/helpers' import open from 'open' -const { version: webTorrentCliVersion } = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url))) +import webTorrentCliVersion from '../version.cjs' const webTorrentVersion = WebTorrent.VERSION const yargs = Yargs() diff --git a/version.cjs b/version.cjs new file mode 100644 index 0000000..738f2a4 --- /dev/null +++ b/version.cjs @@ -0,0 +1,2 @@ +// Exports package.json version to work around "with" and "assert" imports for backwards compatability. +module.exports = require('./package.json').version