|
2 | 2 | import { Command } from 'commander'; |
3 | 3 | import { buildWidgets } from './build'; |
4 | 4 | import { spawn } from 'node:child_process'; |
5 | | -import { existsSync, readFileSync } from 'node:fs'; |
| 5 | +import { readFileSync } from 'node:fs'; |
6 | 6 | import { access } from 'node:fs/promises'; |
7 | 7 | import path from 'node:path'; |
8 | 8 | import open from 'open'; |
9 | 9 | const program = new Command(); |
10 | 10 |
|
11 | 11 |
|
12 | | -// Find the CLI package.json file |
13 | | -function findPackageJson() { |
14 | | - const possiblePaths = [ |
15 | | - path.join(__dirname, '../package.json'), // From dist/ |
16 | | - path.join(__dirname, '../../package.json'), // From dist/ |
17 | | - path.join(process.cwd(), 'package.json'), // Current working directory |
18 | | - ] |
19 | | - |
20 | | - for (const packagePath of possiblePaths) { |
21 | | - if (existsSync(packagePath)) { |
22 | | - return packagePath |
23 | | - } |
24 | | - } |
25 | | - |
26 | | - throw new Error('Could not find package.json file') |
27 | | -} |
28 | | - |
29 | | -const packageContent = readFileSync(findPackageJson(), 'utf-8') |
| 12 | +const packageContent = readFileSync(path.join(__dirname, '../package.json'), 'utf-8') |
30 | 13 | const packageJson = JSON.parse(packageContent) |
31 | 14 | const packageVersion = packageJson.version || 'unknown' |
32 | 15 |
|
|
0 commit comments