Skip to content

Commit b8a9b1a

Browse files
committed
fix: read version from package.json automatically
Instead of hardcoding the version in src/index.ts, now reads it dynamically from package.json. This ensures the CLI version stays in sync with the package version automatically. Now 'emmet -V' will always show the correct version.
1 parent f422562 commit b8a9b1a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env node
22

33
import { Command } from 'commander';
4+
import { readFileSync } from 'fs';
5+
import { join } from 'path';
46
import { expandCommand } from './commands/expand';
57
import { wrapCommand } from './commands/wrap';
68
import { extractCommand } from './commands/extract';
@@ -9,12 +11,17 @@ import { EmmetError } from './types/cli';
911
import { writeStdout, writeStderr } from './utils/output';
1012
import { parseVariables } from './config/merger';
1113

14+
// Read version from package.json
15+
const packageJson = JSON.parse(
16+
readFileSync(join(__dirname, '../package.json'), 'utf-8')
17+
);
18+
1219
const program = new Command();
1320

1421
program
1522
.name('emmet')
1623
.description('VSCode Emmet CLI - Full-featured Emmet abbreviation expansion')
17-
.version('1.0.0');
24+
.version(packageJson.version);
1825

1926
// Global options
2027
program

0 commit comments

Comments
 (0)