From fefa47db37e2e98e266eb9b7bbe9e3b7778d2a13 Mon Sep 17 00:00:00 2001 From: Avi Sharvit Date: Sat, 4 Jan 2020 15:48:41 +0200 Subject: [PATCH] fix(travis-cli): passdown argv to lint command passdown travis-cli argument to @commitlint/cli --- @commitlint/travis-cli/src/cli.js | 6 ++++-- @commitlint/travis-cli/src/cli.test.js | 19 ++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/@commitlint/travis-cli/src/cli.js b/@commitlint/travis-cli/src/cli.js index f6e2177c44..d05b33fe55 100755 --- a/@commitlint/travis-cli/src/cli.js +++ b/@commitlint/travis-cli/src/cli.js @@ -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}); } } diff --git a/@commitlint/travis-cli/src/cli.test.js b/@commitlint/travis-cli/src/cli.test.js index 9b37462aed..79a68d5e84 100644 --- a/@commitlint/travis-cli/src/cli.test.js +++ b/@commitlint/travis-cli/src/cli.test.js @@ -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')); } @@ -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); @@ -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' ]); });