Skip to content

Commit

Permalink
fix: avoid excessive help text #606 (#637)
Browse files Browse the repository at this point in the history
This reverts commit 03da46c.
  • Loading branch information
marionebl committed May 24, 2019
1 parent 48c364c commit b9de149
Show file tree
Hide file tree
Showing 15 changed files with 2,252 additions and 362 deletions.
14 changes: 12 additions & 2 deletions @commitlint/cli/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ const flags = {
alias: 'v',
type: 'boolean',
description: 'display version information'
},
verbose: {
alias: 'V',
type: 'boolean',
description: 'enable verbose output for reports without problems'
}
};

Expand Down Expand Up @@ -204,9 +209,14 @@ async function main(options) {
}
);

const output = format(report, {color: flags.color});
const output = format(report, {
color: flags.color,
verbose: flags.verbose,
helpUrl:
'https://github.com/conventional-changelog/commitlint/#what-is-commitlint'
});

if (!flags.quiet) {
if (!flags.quiet && output !== '') {
console.log(output);
}

Expand Down
33 changes: 29 additions & 4 deletions @commitlint/cli/src/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,45 @@ test('should reprint input from stdin', async t => {
t.true(actual.stdout.includes('foo: bar'));
});

test('should produce no success output with --quiet flag', async t => {
test('should produce success output with --verbose flag', async t => {
const cwd = await git.bootstrap('fixtures/default');
const actual = await cli(['--verbose'], {cwd})('type: bar');
t.true(actual.stdout.includes('0 problems, 0 warnings'));
t.is(actual.stderr, '');
});

test('should produce no output with --quiet flag', async t => {
const cwd = await git.bootstrap('fixtures/default');
const actual = await cli(['--quiet'], {cwd})('foo: bar');
t.is(actual.stdout, '');
t.is(actual.stderr, '');
});

test('should produce no success output with -q flag', async t => {
test('should produce no output with -q flag', async t => {
const cwd = await git.bootstrap('fixtures/default');
const actual = await cli(['-q'], {cwd})('foo: bar');
t.is(actual.stdout, '');
t.is(actual.stderr, '');
});

test('should produce help for empty config', async t => {
const cwd = await git.bootstrap('fixtures/empty');
const actual = await cli([], {cwd})('foo: bar');
t.true(actual.stdout.includes('Please add rules'));
t.is(actual.code, 1);
});

test('should produce help for problems', async t => {
const cwd = await git.bootstrap('fixtures/default');
const actual = await cli([], {cwd})('foo: bar');
t.true(
actual.stdout.includes(
'Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint'
)
);
t.is(actual.code, 1);
});

test('should fail for input from stdin without rules', async t => {
const cwd = await git.bootstrap('fixtures/empty');
const actual = await cli([], {cwd})('foo: bar');
Expand Down Expand Up @@ -259,13 +284,13 @@ test('should print full commit message when input from stdin fails', async t =>
t.is(actual.code, 1);
});

test('should not print full commit message when input succeeds', async t => {
test('should not print commit message fully or partially when input succeeds', async t => {
const cwd = await git.bootstrap('fixtures/default');
const message = 'type: bar\n\nFoo bar bizz buzz.\n\nCloses #123.';
const actual = await cli([], {cwd})(message);

t.false(actual.stdout.includes(message));
t.true(actual.stdout.includes(message.split('\n')[0]));
t.false(actual.stdout.includes(message.split('\n')[0]));
t.is(actual.code, 0);
});

Expand Down
1 change: 1 addition & 0 deletions @commitlint/format/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./lib";
1 change: 1 addition & 0 deletions @commitlint/format/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./lib');
4 changes: 4 additions & 0 deletions @commitlint/format/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node'
};
39 changes: 10 additions & 29 deletions @commitlint/format/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,12 @@
"lib/"
],
"scripts": {
"build": "cross-env NODE_ENV=production babel src --out-dir lib --source-maps",
"build": "tsc",
"deps": "dep-check",
"pkg": "pkg-check --skip-import",
"start": "concurrently \"ava -c 4 --verbose --watch\" \"yarn run watch\"",
"test": "ava -c 4 --verbose",
"watch": "babel src --out-dir lib --watch --source-maps"
},
"ava": {
"files": [
"src/**/*.test.js",
"!lib/**/*"
],
"source": [
"src/**/*.js",
"!lib/**/*"
],
"babel": "inherit",
"require": [
"babel-register"
]
},
"babel": {
"presets": [
"babel-preset-commitlint"
]
"start": "concurrently \"yarn test --watchAll\" \"yarn run watch\"",
"test": "jest",
"watch": "tsc -w"
},
"engines": {
"node": ">=4"
Expand All @@ -58,16 +39,16 @@
"devDependencies": {
"@commitlint/test": "^7.6.0",
"@commitlint/utils": "^7.6.0",
"ava": "0.22.0",
"babel-cli": "6.26.0",
"babel-preset-commitlint": "^7.6.0",
"babel-register": "6.26.0",
"@types/jest": "24.0.12",
"@types/lodash": "4.14.123",
"concurrently": "3.5.1",
"cross-env": "5.1.1",
"lodash": "4.17.11"
"jest": "24.7.1",
"rimraf": "2.6.1",
"ts-jest": "24.0.2",
"typescript": "3.4.5"
},
"dependencies": {
"babel-runtime": "^6.23.0",
"chalk": "^2.0.1"
}
}
Loading

0 comments on commit b9de149

Please sign in to comment.