🌐 AI搜索 & 代理 主页
Skip to content

Commit ff639df

Browse files
authored
feat: add ori --version (#140)
1 parent c38d85b commit ff639df

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

packages/cli/__tests__/__snapshots__/cli.spec.ts.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ exports[`ori --help > A2 1`] = `
44
"Usage: ori <command> [options]
55
66
Options:
7+
-v, --version display version number
78
-h, --help display help for command
89
910
Commands:

packages/cli/__tests__/cli.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
import { formatToLf } from '../src/utils/formatCrlf'
1414

1515
const tempDir = path.resolve(__dirname, '../../temp')
16+
const version = require('../package.json').version
1617

1718
beforeAll(async () => {
1819
await fs.mkdirp(tempDir)
@@ -22,6 +23,12 @@ afterAll(() => {
2223
fs.removeSync(tempDir)
2324
})
2425

26+
test('ori --version', () => {
27+
const { stdout, status } = runSync(['--version'])
28+
expect(stdout).toContain(version)
29+
expect(status).toEqual(0)
30+
})
31+
2532
test('ori --help', () => {
2633
const { stdout, status } = runSync(['--help'])
2734
expect(stdout).toMatchSnapshot('A2')

packages/cli/bin/ori.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ import { codemod, codemodHelp } from '../src/commands/codmod'
55
import { toVite, toViteHelp } from '../src/commands/webpackToVite'
66
const { dev, build } = require('@originjs/cli-service')
77
const program = new Command()
8+
const version = require('../package.json').version
89

10+
program
11+
.name('ori')
12+
.usage('<command> [options]')
13+
.version(version, '-v, --version', 'display version number')
914
program.name('ori').usage('<command> [options]')
1015
program
1116
.command('init <app-name>')

0 commit comments

Comments
 (0)