From f41f95c354fd665552388fdfd521ed228ae9da3c Mon Sep 17 00:00:00 2001 From: "LI, Tai Chen" Date: Mon, 28 Jul 2025 16:34:03 -0400 Subject: [PATCH] fix for importing version from package.json, on globally installed in Windows 11 --- packages/list/lib/index.ts | 4 ++-- packages/terminal/lib/index.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/list/lib/index.ts b/packages/list/lib/index.ts index 955bf9a1e..8ee6cc1cb 100644 --- a/packages/list/lib/index.ts +++ b/packages/list/lib/index.ts @@ -2,9 +2,9 @@ import { autoDetect, PortInfo } from '@serialport/bindings-cpp' import { program, Option } from 'commander' -import { readFileSync } from 'node:fs' +import pkg from '../package.json' assert { type: 'json' }; -const { version } = JSON.parse(readFileSync('../package.json', 'utf8')) +const { version } = pkg; const formatOption = new Option('-f, --format ', 'Format the output').choices(['text', 'json', 'jsonline', 'jsonl']).default('text') diff --git a/packages/terminal/lib/index.ts b/packages/terminal/lib/index.ts index 10cb6ee11..86a36f95b 100755 --- a/packages/terminal/lib/index.ts +++ b/packages/terminal/lib/index.ts @@ -5,9 +5,9 @@ import { program } from 'commander' import { SerialPortStream, OpenOptions } from '@serialport/stream' import { OutputTranslator } from './output-translator' import { autoDetect, AutoDetectTypes } from '@serialport/bindings-cpp' -import { readFileSync } from 'node:fs' +import pkg from '../package.json' assert { type: 'json' }; -const { version } = JSON.parse(readFileSync('../package.json', 'utf8')) +const { version } = pkg; const binding = autoDetect() const makeNumber = (input: string) => Number(input)