From a20e890f6b6c8bacdc511d40cb41f29415bdd044 Mon Sep 17 00:00:00 2001 From: Ben Quarmby Date: Sat, 3 Aug 2024 03:41:39 -0700 Subject: [PATCH] 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 --- @commitlint/cli/src/cli.test.ts | 1 + @commitlint/cli/src/cli.ts | 5 +++++ docs/reference/cli.md | 10 +++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/@commitlint/cli/src/cli.test.ts b/@commitlint/cli/src/cli.test.ts index b30add24d0..6e431a065b 100644 --- a/@commitlint/cli/src/cli.test.ts +++ b/@commitlint/cli/src/cli.test.ts @@ -556,6 +556,7 @@ test('should print help', async () => { -t, --to upper end of the commit range to lint; applies if edit=false [string] -V, --verbose enable verbose output for reports without problems [boolean] -s, --strict enable strict mode; result code 2 for warnings, 3 for errors [boolean] + --options path to a JSON file or Common.js module containing CLI options -v, --version display version information [boolean] -h, --help Show help [boolean]" `); diff --git a/@commitlint/cli/src/cli.ts b/@commitlint/cli/src/cli.ts index b58c047be1..ead3631566 100644 --- a/@commitlint/cli/src/cli.ts +++ b/@commitlint/cli/src/cli.ts @@ -143,6 +143,11 @@ const cli = yargs(process.argv.slice(2)) .alias('v', 'version') .help('help') .alias('h', 'help') + .config( + 'options', + 'path to a JSON file or Common.js module containing CLI options', + require + ) .usage(`${pkg.name}@${pkg.version} - ${pkg.description}\n`) .usage( `[input] reads from stdin if --edit, --env, --from and --to are omitted` diff --git a/docs/reference/cli.md b/docs/reference/cli.md index aa9bf4d2de..9ae669d2ae 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -3,7 +3,7 @@ ```sh ❯ npx commitlint --help -@commitlint/cli@11.0.0 - Lint your commit messages +@commitlint/cli@19.3.0 - Lint your commit messages [input] reads from stdin if --edit, --env, --from and --to are omitted @@ -22,6 +22,10 @@ Options: -H, --help-url help url in error message [string] -f, --from lower end of the commit range to lint; applies if edit=false [string] + --git-log-args additional git log arguments as space separated string, + example '--first-parent --cherry-pick' [string] + -l, --last just analyze the last commit; applies if edit=false + [boolean] -o, --format output format of the results [string] -p, --parser-preset configuration preset to use for conventional-commits-parser [string] @@ -30,6 +34,10 @@ Options: edit=false [string] -V, --verbose enable verbose output for reports without problems [boolean] + -s, --strict enable strict mode; result code 2 for warnings, 3 for + errors [boolean] + --options path to a JSON file or Common.js module containing CLI + options -v, --version display version information [boolean] -h, --help Show help [boolean] ```