Skip to content
This repository was archived by the owner on Apr 8, 2026. It is now read-only.

Commit 2852eea

Browse files
authored
Add --version option to print package version (#62)
1 parent 54e4b0f commit 2852eea

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

src/cli.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import { log } from './lib/logger';
1111
import { OUTPUT_FORMAT } from './lib/types';
1212
import { validate } from './commands/validate';
1313

14+
const { version } = require('../package.json');
15+
16+
commander.version(version);
17+
1418
commander.command('audit')
1519
.description('list the owners for all files')
1620
.option('-d, --dir <dirPath>', 'path to VCS directory', process.cwd())

src/commands/git.test.int.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { generateProject } from './__fixtures__/project-builder.test.helper';
44

55
import util from 'util';
66

7+
const { version } = require('../../package.json');
8+
79
const exec = util.promisify(require('child_process').exec);
810

911
describe('git', () => {
@@ -38,4 +40,11 @@ describe('git', () => {
3840
});
3941
});
4042
}
43+
44+
describe('cli', () => {
45+
it('should print package version', async () => {
46+
const { stdout, stderr } = await runCli('--version');
47+
expect(stdout).toEqual(`${version}\n`);
48+
});
49+
});
4150
});

0 commit comments

Comments
 (0)