Skip to content

Commit fefa47d

Browse files
committed
fix(travis-cli): passdown argv to lint command
passdown travis-cli argument to @commitlint/cli
1 parent 166cbb7 commit fefa47d

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

@commitlint/travis-cli/src/cli.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@ async function main() {
4242
// Restore stashed changes if any
4343
await pop();
4444

45+
const args = process.argv.slice(2);
46+
4547
// Lint all commits in TRAVIS_COMMIT_RANGE if available
4648
if (IS_PR && RANGE) {
4749
const [start, end] = RANGE.split('.').filter(Boolean);
48-
await lint(['--from', start, '--to', end]);
50+
await lint(['--from', start, '--to', end, ...args]);
4951
} else {
5052
const input = await log(COMMIT);
51-
await lint([], {input});
53+
await lint(args, {input});
5254
}
5355
}
5456

@commitlint/travis-cli/src/cli.test.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ const validBaseEnv = {
1818
TRAVIS_PULL_REQUEST_SLUG: 'TRAVIS_PULL_REQUEST_SLUG'
1919
};
2020

21-
const cli = async (config = {}) => {
21+
const cli = async (config = {}, args = []) => {
2222
try {
23-
return await execa(bin, [], config);
23+
return await execa(bin, args, config);
2424
} catch (err) {
2525
throw new Error([err.stdout, err.stderr].join('\n'));
2626
}
@@ -78,10 +78,13 @@ test('should call git with expected args on pull_request', async () => {
7878
TRAVIS_COMMITLINT_GIT_BIN
7979
);
8080

81-
const result = await cli({
82-
cwd,
83-
env: {...validBaseEnv, TRAVIS_EVENT_TYPE: 'pull_request'}
84-
});
81+
const result = await cli(
82+
{
83+
cwd,
84+
env: {...validBaseEnv, TRAVIS_EVENT_TYPE: 'pull_request'}
85+
},
86+
['--config', './config/commitlint.config.js']
87+
);
8588
const invocations = await getInvocations(result.stdout);
8689
expect(invocations.length).toBe(3);
8790

@@ -94,7 +97,9 @@ test('should call git with expected args on pull_request', async () => {
9497
'--from',
9598
'TRAVIS_COMMIT_A',
9699
'--to',
97-
'TRAVIS_COMMIT_B'
100+
'TRAVIS_COMMIT_B',
101+
'--config',
102+
'./config/commitlint.config.js'
98103
]);
99104
});
100105

0 commit comments

Comments
 (0)