Skip to content

Commit

Permalink
fix(travis-cli): passdown argv to lint command
Browse files Browse the repository at this point in the history
passdown travis-cli argument to @commitlint/cli
  • Loading branch information
sharvit committed Feb 7, 2020
1 parent 166cbb7 commit fefa47d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
6 changes: 4 additions & 2 deletions @commitlint/travis-cli/src/cli.js
Expand Up @@ -42,13 +42,15 @@ async function main() {
// Restore stashed changes if any
await pop();

const args = process.argv.slice(2);

// Lint all commits in TRAVIS_COMMIT_RANGE if available
if (IS_PR && RANGE) {
const [start, end] = RANGE.split('.').filter(Boolean);
await lint(['--from', start, '--to', end]);
await lint(['--from', start, '--to', end, ...args]);
} else {
const input = await log(COMMIT);
await lint([], {input});
await lint(args, {input});
}
}

Expand Down
19 changes: 12 additions & 7 deletions @commitlint/travis-cli/src/cli.test.js
Expand Up @@ -18,9 +18,9 @@ const validBaseEnv = {
TRAVIS_PULL_REQUEST_SLUG: 'TRAVIS_PULL_REQUEST_SLUG'
};

const cli = async (config = {}) => {
const cli = async (config = {}, args = []) => {
try {
return await execa(bin, [], config);
return await execa(bin, args, config);
} catch (err) {
throw new Error([err.stdout, err.stderr].join('\n'));
}
Expand Down Expand Up @@ -78,10 +78,13 @@ test('should call git with expected args on pull_request', async () => {
TRAVIS_COMMITLINT_GIT_BIN
);

const result = await cli({
cwd,
env: {...validBaseEnv, TRAVIS_EVENT_TYPE: 'pull_request'}
});
const result = await cli(
{
cwd,
env: {...validBaseEnv, TRAVIS_EVENT_TYPE: 'pull_request'}
},
['--config', './config/commitlint.config.js']
);
const invocations = await getInvocations(result.stdout);
expect(invocations.length).toBe(3);

Expand All @@ -94,7 +97,9 @@ test('should call git with expected args on pull_request', async () => {
'--from',
'TRAVIS_COMMIT_A',
'--to',
'TRAVIS_COMMIT_B'
'TRAVIS_COMMIT_B',
'--config',
'./config/commitlint.config.js'
]);
});

Expand Down

0 comments on commit fefa47d

Please sign in to comment.