Skip to content

Commit 480df29

Browse files
committedApr 16, 2024
fix(cli): load --version from package.json
Currently, this value is hard coded, which isn't great, since it means we need to update the value in two places each time we make a new release. This is a bit slower than the old version, but it shouldn't be too much slower, unless the user is still using a HDD.
1 parent 3211343 commit 480df29

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed
 

‎packages/cli/src/commander.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
} from '@commander-js/extra-typings';
77
import { readFile, writeFile } from 'fs/promises';
88
import { MermaidChart } from '@mermaidchart/sdk';
9-
9+
import { createRequire } from 'node:module';
1010
import input from '@inquirer/input';
1111
import select, { Separator } from '@inquirer/select';
1212
import { type Config, defaultConfigPath, readConfig, writeConfig } from './config.js';
@@ -234,8 +234,11 @@ function pushCmd() {
234234
}
235235

236236
export function createCommanderCommand() {
237+
const require = createRequire(import.meta.url);
238+
const pkg = require('../package.json');
239+
237240
const program = createCommand('mermaid-cli')
238-
.version('0.1.0-alpha.0') // TODO: how can we keep this synced with package.json
241+
.version(pkg.version)
239242
.description(
240243
'CLI for interacting with https://MermaidChart.com, the platform that makes collaborating with Mermaid diagrams easy.',
241244
)

0 commit comments

Comments
 (0)
Failed to load comments.