Skip to content

Commit a20e890

Browse files
authored
feat: support command line options from a file (#4109)
* docs: add missing CLI options * feat: support CLI options from JSON file or Common.js module
1 parent 722d8ff commit a20e890

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

@commitlint/cli/src/cli.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ test('should print help', async () => {
556556
-t, --to upper end of the commit range to lint; applies if edit=false [string]
557557
-V, --verbose enable verbose output for reports without problems [boolean]
558558
-s, --strict enable strict mode; result code 2 for warnings, 3 for errors [boolean]
559+
--options path to a JSON file or Common.js module containing CLI options
559560
-v, --version display version information [boolean]
560561
-h, --help Show help [boolean]"
561562
`);

@commitlint/cli/src/cli.ts

+5
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ const cli = yargs(process.argv.slice(2))
143143
.alias('v', 'version')
144144
.help('help')
145145
.alias('h', 'help')
146+
.config(
147+
'options',
148+
'path to a JSON file or Common.js module containing CLI options',
149+
require
150+
)
146151
.usage(`${pkg.name}@${pkg.version} - ${pkg.description}\n`)
147152
.usage(
148153
`[input] reads from stdin if --edit, --env, --from and --to are omitted`

docs/reference/cli.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
```sh
44
❯ npx commitlint --help
55

6-
@commitlint/cli@11.0.0 - Lint your commit messages
6+
@commitlint/cli@19.3.0 - Lint your commit messages
77

88
[input] reads from stdin if --edit, --env, --from and --to are omitted
99

@@ -22,6 +22,10 @@ Options:
2222
-H, --help-url help url in error message [string]
2323
-f, --from lower end of the commit range to lint; applies if
2424
edit=false [string]
25+
--git-log-args additional git log arguments as space separated string,
26+
example '--first-parent --cherry-pick' [string]
27+
-l, --last just analyze the last commit; applies if edit=false
28+
[boolean]
2529
-o, --format output format of the results [string]
2630
-p, --parser-preset configuration preset to use for
2731
conventional-commits-parser [string]
@@ -30,6 +34,10 @@ Options:
3034
edit=false [string]
3135
-V, --verbose enable verbose output for reports without problems
3236
[boolean]
37+
-s, --strict enable strict mode; result code 2 for warnings, 3 for
38+
errors [boolean]
39+
--options path to a JSON file or Common.js module containing CLI
40+
options
3341
-v, --version display version information [boolean]
3442
-h, --help Show help [boolean]
3543
```

0 commit comments

Comments
 (0)