Skip to content

Commit eab1689

Browse files
committed
Fix crashes from missing package.json
Previously `npx @serialport/list` and `npx @serialport/terminal` would crash as they would search the local filesystem for package.json to find the version. Now these tools print the correct version.
1 parent 7160182 commit eab1689

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

packages/list/lib/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
import { autoDetect, PortInfo } from '@serialport/bindings-cpp'
44
import { program, Option } from 'commander'
5-
import { readFileSync } from 'node:fs'
65

7-
const { version } = JSON.parse(readFileSync('../package.json', 'utf8'))
6+
const { version } = module.require('@serialport/list/package.json')
87

98
const formatOption = new Option('-f, --format <type>', 'Format the output').choices(['text', 'json', 'jsonline', 'jsonl']).default('text')
109

packages/terminal/lib/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import { program } from 'commander'
55
import { SerialPortStream, OpenOptions } from '@serialport/stream'
66
import { OutputTranslator } from './output-translator'
77
import { autoDetect, AutoDetectTypes } from '@serialport/bindings-cpp'
8-
import { readFileSync } from 'node:fs'
98

10-
const { version } = JSON.parse(readFileSync('../package.json', 'utf8'))
9+
const { version } = module.require('@serialport/terminal/package.json')
1110
const binding = autoDetect()
1211

1312
const makeNumber = (input: string) => Number(input)

0 commit comments

Comments
 (0)