|
| 1 | +import {describe, test, expect} from 'vitest'; |
| 2 | +import {createRequire} from 'module'; |
| 3 | +import path from 'path'; |
| 4 | +import {fileURLToPath} from 'url'; |
| 5 | + |
1 | 6 | import {fix, git} from '@commitlint/test';
|
2 | 7 | import execa from 'execa';
|
3 | 8 | import fs from 'fs-extra';
|
4 | 9 | import merge from 'lodash.merge';
|
5 |
| -import path from 'path'; |
| 10 | + |
| 11 | +const require = createRequire(import.meta.url); |
| 12 | + |
| 13 | +const __dirname = path.resolve(fileURLToPath(import.meta.url), '..'); |
6 | 14 |
|
7 | 15 | const bin = require.resolve('../cli.js');
|
8 | 16 |
|
@@ -511,34 +519,24 @@ test('should print help', async () => {
|
511 | 519 | [input] reads from stdin if --edit, --env, --from and --to are omitted
|
512 | 520 |
|
513 | 521 | Options:
|
514 |
| - -c, --color toggle colored output [boolean] [default: true] |
515 |
| - -g, --config path to the config file [string] |
516 |
| - --print-config print resolved config |
517 |
| - [string] [choices: "", "text", "json"] |
518 |
| - -d, --cwd directory to execute in |
519 |
| - [string] [default: (Working Directory)] |
520 |
| - -e, --edit read last commit message from the specified file or |
521 |
| - fallbacks to ./.git/COMMIT_EDITMSG [string] |
522 |
| - -E, --env check message in the file at path given by environment |
523 |
| - variable value [string] |
524 |
| - -x, --extends array of shareable configurations to extend [array] |
525 |
| - -H, --help-url help url in error message [string] |
526 |
| - -f, --from lower end of the commit range to lint; applies if |
527 |
| - edit=false [string] |
528 |
| - --git-log-args additional git log arguments as space separated string, |
529 |
| - example '--first-parent --cherry-pick' [string] |
530 |
| - -o, --format output format of the results [string] |
531 |
| - -p, --parser-preset configuration preset to use for |
532 |
| - conventional-commits-parser [string] |
533 |
| - -q, --quiet toggle console output [boolean] [default: false] |
534 |
| - -t, --to upper end of the commit range to lint; applies if |
535 |
| - edit=false [string] |
536 |
| - -V, --verbose enable verbose output for reports without problems |
537 |
| - [boolean] |
538 |
| - -s, --strict enable strict mode; result code 2 for warnings, 3 for |
539 |
| - errors [boolean] |
540 |
| - -v, --version display version information [boolean] |
541 |
| - -h, --help Show help [boolean]" |
| 522 | + -c, --color toggle colored output [boolean] [default: true] |
| 523 | + -g, --config path to the config file [string] |
| 524 | + --print-config print resolved config [string] [choices: "", "text", "json"] |
| 525 | + -d, --cwd directory to execute in [string] [default: (Working Directory)] |
| 526 | + -e, --edit read last commit message from the specified file or fallbacks to ./.git/COMMIT_EDITMSG [string] |
| 527 | + -E, --env check message in the file at path given by environment variable value [string] |
| 528 | + -x, --extends array of shareable configurations to extend [array] |
| 529 | + -H, --help-url help url in error message [string] |
| 530 | + -f, --from lower end of the commit range to lint; applies if edit=false [string] |
| 531 | + --git-log-args additional git log arguments as space separated string, example '--first-parent --cherry-pick' [string] |
| 532 | + -o, --format output format of the results [string] |
| 533 | + -p, --parser-preset configuration preset to use for conventional-commits-parser [string] |
| 534 | + -q, --quiet toggle console output [boolean] [default: false] |
| 535 | + -t, --to upper end of the commit range to lint; applies if edit=false [string] |
| 536 | + -V, --verbose enable verbose output for reports without problems [boolean] |
| 537 | + -s, --strict enable strict mode; result code 2 for warnings, 3 for errors [boolean] |
| 538 | + -v, --version display version information [boolean] |
| 539 | + -h, --help Show help [boolean]" |
542 | 540 | `);
|
543 | 541 | });
|
544 | 542 |
|
@@ -600,7 +598,7 @@ describe('should print config', () => {
|
600 | 598 | const actual = await cli(['--print-config=json', '--no-color'], {cwd})();
|
601 | 599 |
|
602 | 600 | expect(actual.stdout).toMatchInlineSnapshot(
|
603 |
| - `"{"extends":[],"formatter":"@commitlint/format","plugins":{},"rules":{"type-enum":[2,"never",["foo"]]},"helpUrl":"https://github.com/conventional-changelog/commitlint/#what-is-commitlint\","prompt":{}}"` |
| 601 | + `"{"extends":[],"formatter":"@commitlint/format","plugins":{},"rules":{"type-enum":[2,"never",["foo"]]},"helpUrl":"https://github.com/conventional-changelog/commitlint/#what-is-commitlint","prompt":{}}"` |
604 | 602 | );
|
605 | 603 | });
|
606 | 604 | });
|
|
0 commit comments