Skip to content

Commit

Permalink
fix: cleanup message for input with no config (#519)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
escapedcat authored and marionebl committed Jan 27, 2019
1 parent 83b1a47 commit 7d9e760
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions @commitlint/cli/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand All @@ -166,7 +173,7 @@ async function main(options) {
}
],
warnings: [],
input: ''
input
});
}

Expand Down
2 changes: 1 addition & 1 deletion @commitlint/format/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 7d9e760

Please sign in to comment.