Skip to content

Commit d266622

Browse files
committed
fix: --version option
1 parent 2dfc980 commit d266622

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/bin.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
3-
import { extname, join } from 'node:path'
3+
import { extname } from 'node:path'
44
import { parseArgs } from 'node:util'
55

66
import chalk from 'chalk'
@@ -10,6 +10,7 @@ import { Adapter, Low } from 'lowdb'
1010
import { DataFile, JSONFile } from 'lowdb/node'
1111
import { PackageJson } from 'type-fest'
1212

13+
import { fileURLToPath } from 'node:url'
1314
import { createApp } from './app.js'
1415
import { Observer } from './observer.js'
1516
import { Data } from './service.js'
@@ -70,7 +71,10 @@ function args(): {
7071
// --version
7172
if (values.version) {
7273
const pkg = JSON.parse(
73-
readFileSync(join(__dirname, '../package.json'), 'utf8'),
74+
readFileSync(
75+
fileURLToPath(new URL('../package.json', import.meta.url)),
76+
'utf-8',
77+
),
7478
) as PackageJson
7579
console.log(pkg.version)
7680
process.exit()

0 commit comments

Comments
 (0)