From 7d9e76006fd5ccb77e7d79f09dc4e1d93bb2bc85 Mon Sep 17 00:00:00 2001 From: hannes Date: Sun, 27 Jan 2019 20:46:10 +0100 Subject: [PATCH] fix: cleanup message for input with no config (#519) * fix(cli): cleanup message for input with no config * chore(format): remove linebreaks from output this let to too many linebreaks in certain situations * refactor(cli): empty results on no-config --- @commitlint/cli/src/cli.js | 11 +++++++++-- @commitlint/format/src/index.js | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/@commitlint/cli/src/cli.js b/@commitlint/cli/src/cli.js index 8109af9997..cadc49f557 100755 --- a/@commitlint/cli/src/cli.js +++ b/@commitlint/cli/src/cli.js @@ -151,7 +151,14 @@ async function main(options) { ); if (Object.keys(loaded.rules).length === 0) { - results.push({ + let input = ''; + + if (results.length !== 0) { + const originalInput = results[0].input; + input = originalInput; + } + + results.splice(0, results.length, { valid: false, errors: [ { @@ -166,7 +173,7 @@ async function main(options) { } ], warnings: [], - input: '' + input }); } diff --git a/@commitlint/format/src/index.js b/@commitlint/format/src/index.js index 1a1daa89c5..8980f95731 100644 --- a/@commitlint/format/src/index.js +++ b/@commitlint/format/src/index.js @@ -31,7 +31,7 @@ function formatInput(result = {}, options = {}) { const sign = '⧗'; const decoration = enabled ? chalk.gray(sign) : sign; - const commitText = errors.length > 0 ? `\n${input}\n` : input.split('\n')[0]; + const commitText = errors.length > 0 ? input : input.split('\n')[0]; const decoratedInput = enabled ? chalk.bold(commitText) : commitText;