From 4899bb2edf2b56e8a30dc8e6dfac2f08023e9ee9 Mon Sep 17 00:00:00 2001 From: Ben Quarmby Date: Tue, 30 Jul 2024 15:39:45 -0700 Subject: [PATCH] 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 | 2 ++ 3 files changed, 8 insertions(+) diff --git a/@commitlint/cli/src/cli.test.ts b/@commitlint/cli/src/cli.test.ts index b30add24d05..6e431a065b3 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 b58c047be18..ead36315661 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 ca3b3c64bc8..9ae669d2ae3 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -36,6 +36,8 @@ Options: [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] ```