Skip to content

Commit e869e16

Browse files
committed
test(cli): use more descriptive name for cwd
1 parent a048e9e commit e869e16

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

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

+3-9
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,8 @@ test('should work with relative formatter path', async () => {
430430

431431
test('should print help', async () => {
432432
const cwd = await gitBootstrap('fixtures/default');
433-
const actual = await cli(['--help'], {cwd})();
434-
expect(escapeCwd(actual.stdout, cwd)).toMatchInlineSnapshot(`
433+
const actual = await cli(['--help', '--cwd', './'], {cwd})();
434+
expect(actual.stdout).toMatchInlineSnapshot(`
435435
"@commitlint/[email protected] - Lint your commit messages
436436
437437
[input] reads from stdin if --edit, --env, --from and --to are omitted
@@ -440,7 +440,7 @@ test('should print help', async () => {
440440
--color, -c toggle colored output [boolean] [default: true]
441441
--config, -g path to the config file [string]
442442
--cwd, -d directory to execute in
443-
[string] [default: \\"__CWD__\\"]
443+
[string] [default: (Working Directory)]
444444
--edit, -e read last commit message from the specified file or
445445
fallbacks to ./.git/COMMIT_EDITMSG
446446
[string] [default: false]
@@ -475,9 +475,3 @@ async function writePkg(payload: unknown, options: TestOptions) {
475475
const result = merge(pkg, payload);
476476
await fs.writeFile(pkgPath, JSON.stringify(result, null, ' '));
477477
}
478-
479-
function escapeCwd(value: string, cwd: string): string {
480-
return value
481-
.replace(cwd, '__CWD__')
482-
.replace(/(\n[ ]+)(.+__CWD__)/, `$1${' '.repeat(cwd.length - 7)}$2`);
483-
}

@commitlint/cli/src/cli.ts

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const cli = yargs
3636
cwd: {
3737
alias: 'd',
3838
default: process.cwd(),
39+
defaultDescription: '(Working Directory)',
3940
description: 'directory to execute in',
4041
type: 'string'
4142
},

0 commit comments

Comments
 (0)