Skip to content

Commit

Permalink
refactor: optimize command parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
a145789 committed Dec 12, 2023
1 parent f6dc9c3 commit 76aab5d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 19 deletions.
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ npx vr changelog -f changelog.md
npx vr changelog --file changelog.md

# Lint commit message
npx vr lint-commit .git/COMMIT_EDITMSG
npx vr lint-commit -p .git/COMMIT_EDITMSG
```

### Configuration
Expand All @@ -75,12 +75,12 @@ npx vr lint-commit .git/COMMIT_EDITMSG

#### lint-commit

| Params | Instructions |
| -------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| \<commitMessagePath\> | The path of the temporary file to which the git message is submitted. The git hook commit-msg will pass this parameter |
| -cmr --commitMessageRe \<reg\> | Validate the regular of whether the commit message passes |
| -em --errorMessage \<message\> | Validation failed to display error messages |
| -wm --warningMessage \<message\> | Validation failed to display warning messages |
| Params | Instructions |
| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| -p --commitMessagePath \<path\> | The path of the temporary file to which the git message is submitted. The git hook commit-msg will pass this parameter |
| -r --commitMessageRe \<reg\> | Validate the regular of whether the commit message passes |
| -e --errorMessage \<message\> | Validation failed to display error messages |
| -w --warningMessage \<message\> | Validation failed to display warning messages |

### Custom Handle

Expand Down Expand Up @@ -120,7 +120,14 @@ interface ChangelogCommandOptions {
releaseCount?: number
}
function changelog({ releaseCount, file }?: ChangelogCommandOptions): Promise<void>
function commitLint(commitMessagePath: string): void

interface CommitLintCommandOptions {
commitMessagePath: string
commitMessageRe?: string | RegExp
errorMessage?: string
warningMessage?: string
}
function commitLint(options: CommitLintCommandOptions): void
```

## License
Expand Down
23 changes: 15 additions & 8 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ npx vr changelog -f changelog.md
npx vr changelog --file changelog.md

# 检测 commit message
npx vr lint-commit .git/COMMIT_EDITMSG
npx vr lint-commit -p .git/COMMIT_EDITMSG
```

### 配置
Expand All @@ -75,12 +75,12 @@ npx vr lint-commit .git/COMMIT_EDITMSG

#### lint-commit

| 参数 | 说明 |
| -------------------------------- | --------------------------------------------------------------------------- |
| \<commitMessagePath\> | 提交 `git message` 的临时文件路径。`git` 钩子 `commit-msg` 会传递这个参数。 |
| -cmr --commitMessageRe \<reg\> | 验证 `commit message` 是否通过的正则 |
| -em --errorMessage \<message\> | 验证失败展示的错误信息 |
| -wm --warningMessage \<message\> | 验证失败展示的提示信息 |
| 参数 | 说明 |
| ------------------------------- | --------------------------------------------------------------------------- |
| -p --commitMessagePath \<path\> | 提交 `git message` 的临时文件路径。`git` 钩子 `commit-msg` 会传递这个参数。 |
| -r --commitMessageRe \<reg\> | 验证 `commit message` 是否通过的正则 |
| -e --errorMessage \<message\> | 验证失败展示的错误信息 |
| -w --warningMessage \<message\> | 验证失败展示的提示信息 |

### 自定义处理

Expand Down Expand Up @@ -120,7 +120,14 @@ interface ChangelogCommandOptions {
releaseCount?: number
}
function changelog({ releaseCount, file }?: ChangelogCommandOptions): Promise<void>
function commitLint(commitMessagePath: string): void

interface CommitLintCommandOptions {
commitMessagePath: string
commitMessageRe?: string | RegExp
errorMessage?: string
warningMessage?: string
}
function commitLint(options: CommitLintCommandOptions): void
```

## License
Expand Down
6 changes: 3 additions & 3 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ program
program
.command('commit-lint')
.option('-p --commitMessagePath <commitMessagePath>', 'Git commit message path')
.option('-cmr --commitMessageRe <reg>', 'Validate the regular of whether the commit message passes')
.option('-em --errorMessage <message>', 'Validation failed to display error messages')
.option('-wm --warningMessage <message>', 'Validation failed to display warning messages')
.option('-r --commitMessageRe <reg>', 'Validate the regular of whether the commit message passes')
.option('-e --errorMessage <message>', 'Validation failed to display error messages')
.option('-w --warningMessage <message>', 'Validation failed to display warning messages')
.description('Lint commit message')
.action(async (option) => commitLint(option))

Expand Down

0 comments on commit 76aab5d

Please sign in to comment.