@commitlint/format 7.0.0 → 7.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +34 -18
- package/lib/index.js +47 -12
- package/lib/index.js.map +1 -1
- package/lib/index.test.js +78 -74
- package/lib/index.test.js.map +1 -1
- package/license.md +21 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
<a name="7.2.1"></a>
|
|
7
|
+
## [7.2.1](https://github.com/marionebl/commitlint/compare/v7.2.0...v7.2.1) (2018-10-11)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @commitlint/format
|
|
13
|
+
|
|
14
|
+
<a name="7.2.0"></a>
|
|
15
|
+
# [7.2.0](https://github.com/marionebl/commitlint/compare/v7.1.2...v7.2.0) (2018-10-05)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
**Note:** Version bump only for package @commitlint/format
|
|
21
|
+
|
|
22
|
+
<a name="7.1.2"></a>
|
|
23
|
+
## [7.1.2](https://github.com/marionebl/commitlint/compare/v7.1.1...v7.1.2) (2018-09-04)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
**Note:** Version bump only for package @commitlint/format
|
|
29
|
+
|
|
6
30
|
<a name="6.1.1"></a>
|
|
7
31
|
## [6.1.1](https://github.com/marionebl/commitlint/compare/v6.1.0...v6.1.1) (2018-02-22)
|
|
8
32
|
|
package/README.md
CHANGED
|
@@ -13,29 +13,44 @@ npm install --save @commitlint/format
|
|
|
13
13
|
```js
|
|
14
14
|
const format = require('@commitlint/format');
|
|
15
15
|
|
|
16
|
-
format({
|
|
17
|
-
|
|
16
|
+
const output = format({
|
|
17
|
+
valid: false,
|
|
18
|
+
errorCount: 1,
|
|
19
|
+
warningCount: 1,
|
|
20
|
+
results: [
|
|
18
21
|
{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
valid: false,
|
|
23
|
+
input: 'some: commit message',
|
|
24
|
+
errors: [
|
|
25
|
+
{
|
|
26
|
+
valid: false,
|
|
27
|
+
level: 2,
|
|
28
|
+
name: 'some-error',
|
|
29
|
+
message: 'This will show up red as it has level 2'
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
warnings: [
|
|
33
|
+
{
|
|
34
|
+
valid: true,
|
|
35
|
+
level: 0,
|
|
36
|
+
name: 'some-hint',
|
|
37
|
+
message: 'This will not show up as it has level 0'
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
valid: false,
|
|
41
|
+
level: 1,
|
|
42
|
+
name: 'some-warning',
|
|
43
|
+
message: 'This will show up yellow as it has level 1'
|
|
44
|
+
}
|
|
45
|
+
]
|
|
34
46
|
}
|
|
35
|
-
]
|
|
47
|
+
]
|
|
36
48
|
}, {
|
|
37
49
|
color: false
|
|
38
50
|
});
|
|
51
|
+
|
|
52
|
+
process.stdout.write(output);
|
|
53
|
+
|
|
39
54
|
/* => [
|
|
40
55
|
'✖ This will show up red as it has level 2 [some-error]',
|
|
41
56
|
' This will not show up as it has level 0 [some-hint]',
|
|
@@ -45,3 +60,4 @@ format({
|
|
|
45
60
|
```
|
|
46
61
|
|
|
47
62
|
Consult [docs/api](http://marionebl.github.io/commitlint/#/reference-api) for comprehensive documentation.
|
|
63
|
+
|
package/lib/index.js
CHANGED
|
@@ -15,16 +15,51 @@ const DEFAULT_SIGNS = [' ', '⚠', '✖'];
|
|
|
15
15
|
const DEFAULT_COLORS = ['white', 'yellow', 'red'];
|
|
16
16
|
|
|
17
17
|
function format(report = {}, options = {}) {
|
|
18
|
+
var _report$results = report.results;
|
|
19
|
+
const results = _report$results === undefined ? [] : _report$results;
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
if (results.length > 0) {
|
|
23
|
+
return results.map(result => `${formatInput(result, options)}${formatResult(result, options).join('\n')}`).join('\n');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Output a summary when nothing is found
|
|
27
|
+
return formatResult({}, options).join('\n');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function formatInput(result = {}, options = {}) {
|
|
31
|
+
var _options$color = options.color;
|
|
32
|
+
const enabled = _options$color === undefined ? true : _options$color;
|
|
33
|
+
var _result$errors = result.errors;
|
|
34
|
+
const errors = _result$errors === undefined ? [] : _result$errors;
|
|
35
|
+
var _result$input = result.input;
|
|
36
|
+
const input = _result$input === undefined ? '' : _result$input;
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
if (!input) {
|
|
40
|
+
return '';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const sign = '⧗';
|
|
44
|
+
const decoration = enabled ? _chalk2.default.gray(sign) : sign;
|
|
45
|
+
const commitText = errors.length > 0 ? `\n${input}\n` : input.split('\n')[0];
|
|
46
|
+
|
|
47
|
+
const decoratedInput = enabled ? _chalk2.default.bold(commitText) : commitText;
|
|
48
|
+
|
|
49
|
+
return `\n${decoration} input: ${decoratedInput}\n`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function formatResult(result = {}, options = {}) {
|
|
18
53
|
var _options$signs = options.signs;
|
|
19
54
|
const signs = _options$signs === undefined ? DEFAULT_SIGNS : _options$signs;
|
|
20
55
|
var _options$colors = options.colors;
|
|
21
56
|
const colors = _options$colors === undefined ? DEFAULT_COLORS : _options$colors;
|
|
22
|
-
var _options$
|
|
23
|
-
const enabled = _options$
|
|
24
|
-
var
|
|
25
|
-
const errors =
|
|
26
|
-
var
|
|
27
|
-
const warnings =
|
|
57
|
+
var _options$color2 = options.color;
|
|
58
|
+
const enabled = _options$color2 === undefined ? true : _options$color2;
|
|
59
|
+
var _result$errors2 = result.errors;
|
|
60
|
+
const errors = _result$errors2 === undefined ? [] : _result$errors2;
|
|
61
|
+
var _result$warnings = result.warnings;
|
|
62
|
+
const warnings = _result$warnings === undefined ? [] : _result$warnings;
|
|
28
63
|
|
|
29
64
|
|
|
30
65
|
const problems = [...errors, ...warnings].map(problem => {
|
|
@@ -43,18 +78,18 @@ function format(report = {}, options = {}) {
|
|
|
43
78
|
return [...problems, enabled ? _chalk2.default.bold(summary) : summary];
|
|
44
79
|
}
|
|
45
80
|
|
|
46
|
-
function selectSign(
|
|
47
|
-
if (
|
|
81
|
+
function selectSign(result) {
|
|
82
|
+
if (result.errors.length > 0) {
|
|
48
83
|
return '✖';
|
|
49
84
|
}
|
|
50
|
-
return
|
|
85
|
+
return result.warnings.length ? '⚠' : '✔';
|
|
51
86
|
}
|
|
52
87
|
|
|
53
|
-
function selectColor(
|
|
54
|
-
if (
|
|
88
|
+
function selectColor(result) {
|
|
89
|
+
if (result.errors.length > 0) {
|
|
55
90
|
return 'red';
|
|
56
91
|
}
|
|
57
|
-
return
|
|
92
|
+
return result.warnings.length ? 'yellow' : 'green';
|
|
58
93
|
}
|
|
59
94
|
module.exports = exports['default'];
|
|
60
95
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["format","DEFAULT_SIGNS","DEFAULT_COLORS","report","options","
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["format","DEFAULT_SIGNS","DEFAULT_COLORS","report","options","results","length","map","result","formatInput","formatResult","join","color","enabled","errors","input","sign","decoration","gray","commitText","split","decoratedInput","bold","signs","colors","warnings","problems","problem","level","name","grey","message","selectSign","selectColor","summary"],"mappings":";;;;;kBAKwB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,UAAW,GAAEjB,UAAW,YAAWH,OAAOR,MAAO,cACtDmB,SAASnB,MACT,WAFD;AAGA,QAAO,CAAC,GAAGoB,QAAJ,EAAcb,UAAU,gBAAMS,IAAN,CAAWY,OAAX,CAAV,GAAgCA,OAA9C,CAAP;AACA;;AAED,SAASF,UAAT,CAAoBxB,MAApB,EAA4B;AAC3B,KAAIA,OAAOM,MAAP,CAAcR,MAAd,GAAuB,CAA3B,EAA8B;AAC7B,SAAO,GAAP;AACA;AACD,QAAOE,OAAOiB,QAAP,CAAgBnB,MAAhB,GAAyB,GAAzB,GAA+B,GAAtC;AACA;;AAED,SAAS2B,WAAT,CAAqBzB,MAArB,EAA6B;AAC5B,KAAIA,OAAOM,MAAP,CAAcR,MAAd,GAAuB,CAA3B,EAA8B;AAC7B,SAAO,KAAP;AACA;AACD,QAAOE,OAAOiB,QAAP,CAAgBnB,MAAhB,GAAyB,QAAzB,GAAoC,OAA3C;AACA","file":"index.js","sourcesContent":["import chalk from 'chalk';\n\nconst DEFAULT_SIGNS = [' ', '⚠', '✖'];\nconst DEFAULT_COLORS = ['white', 'yellow', 'red'];\n\nexport default function format(report = {}, options = {}) {\n\tconst {results = []} = report;\n\n\tif (results.length > 0) {\n\t\treturn results\n\t\t\t.map(\n\t\t\t\tresult =>\n\t\t\t\t\t`${formatInput(result, options)}${formatResult(result, options).join(\n\t\t\t\t\t\t'\\n'\n\t\t\t\t\t)}`\n\t\t\t)\n\t\t\t.join('\\n');\n\t}\n\n\t// Output a summary when nothing is found\n\treturn formatResult({}, options).join('\\n');\n}\n\nfunction formatInput(result = {}, options = {}) {\n\tconst {color: enabled = true} = options;\n\tconst {errors = [], input = ''} = result;\n\n\tif (!input) {\n\t\treturn '';\n\t}\n\n\tconst sign = '⧗';\n\tconst decoration = enabled ? chalk.gray(sign) : sign;\n\tconst commitText = errors.length > 0 ? `\\n${input}\\n` : input.split('\\n')[0];\n\n\tconst decoratedInput = enabled ? chalk.bold(commitText) : commitText;\n\n\treturn `\\n${decoration} input: ${decoratedInput}\\n`;\n}\n\nfunction formatResult(result = {}, options = {}) {\n\tconst {\n\t\tsigns = DEFAULT_SIGNS,\n\t\tcolors = DEFAULT_COLORS,\n\t\tcolor: enabled = true\n\t} = options;\n\tconst {errors = [], warnings = []} = result;\n\n\tconst problems = [...errors, ...warnings].map(problem => {\n\t\tconst sign = signs[problem.level] || '';\n\t\tconst color = colors[problem.level] || 'white';\n\t\tconst decoration = enabled ? chalk[color](sign) : sign;\n\t\tconst name = enabled\n\t\t\t? chalk.grey(`[${problem.name}]`)\n\t\t\t: `[${problem.name}]`;\n\t\treturn `${decoration} ${problem.message} ${name}`;\n\t});\n\n\tconst sign = selectSign({errors, warnings});\n\tconst color = selectColor({errors, warnings});\n\n\tconst decoration = enabled ? chalk[color](sign) : sign;\n\tconst summary = `${decoration} found ${errors.length} problems, ${\n\t\twarnings.length\n\t} warnings`;\n\treturn [...problems, enabled ? chalk.bold(summary) : summary];\n}\n\nfunction selectSign(result) {\n\tif (result.errors.length > 0) {\n\t\treturn '✖';\n\t}\n\treturn result.warnings.length ? '⚠' : '✔';\n}\n\nfunction selectColor(result) {\n\tif (result.errors.length > 0) {\n\t\treturn 'red';\n\t}\n\treturn result.warnings.length ? 'yellow' : 'green';\n}\n"]}
|
package/lib/index.test.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var _slicedToArray2 = require('babel-runtime/helpers/slicedToArray');
|
|
4
|
-
|
|
5
|
-
var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);
|
|
6
|
-
|
|
7
3
|
var _ava = require('ava');
|
|
8
4
|
|
|
9
5
|
var _ava2 = _interopRequireDefault(_ava);
|
|
@@ -26,97 +22,105 @@ const ok = _chalk2.default.bold(`${_chalk2.default.green('✔')} found 0 probl
|
|
|
26
22
|
|
|
27
23
|
(0, _ava2.default)('does nothing without arguments', t => {
|
|
28
24
|
const actual = (0, _2.default)();
|
|
29
|
-
t.deepEqual(actual,
|
|
25
|
+
t.deepEqual(actual, ok);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
(0, _ava2.default)('does nothing without report results', t => {
|
|
29
|
+
const actual = (0, _2.default)({ results: [] });
|
|
30
|
+
t.deepEqual(actual, ok);
|
|
30
31
|
});
|
|
31
32
|
|
|
32
33
|
(0, _ava2.default)('does nothing without .errors and .warnings', t => {
|
|
33
|
-
const actual = (0, _2.default)({});
|
|
34
|
-
t.deepEqual(actual,
|
|
34
|
+
const actual = (0, _2.default)({ results: [{}] });
|
|
35
|
+
t.deepEqual(actual, ok);
|
|
35
36
|
});
|
|
36
37
|
|
|
37
38
|
(0, _ava2.default)('returns empty summary of problems for empty .errors and .warnings', t => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const msg = _format2[0];
|
|
45
|
-
|
|
39
|
+
const actual = (0, _2.default)({
|
|
40
|
+
results: [{
|
|
41
|
+
errors: [],
|
|
42
|
+
warnings: []
|
|
43
|
+
}]
|
|
44
|
+
});
|
|
46
45
|
|
|
47
|
-
t.true(
|
|
46
|
+
t.true(actual.includes('0 problems, 0 warnings'));
|
|
48
47
|
});
|
|
49
48
|
|
|
50
49
|
(0, _ava2.default)('returns a correct of empty .errors and .warnings', t => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
level: 1,
|
|
59
|
-
name: 'warning-name',
|
|
60
|
-
message: 'There was a problem'
|
|
50
|
+
const actualError = (0, _2.default)({
|
|
51
|
+
results: [{
|
|
52
|
+
errors: [{
|
|
53
|
+
level: 2,
|
|
54
|
+
name: 'error-name',
|
|
55
|
+
message: 'There was an error'
|
|
56
|
+
}]
|
|
61
57
|
}]
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const actualWarning = (0, _2.default)({
|
|
61
|
+
results: [{
|
|
62
|
+
warnings: [{
|
|
63
|
+
level: 1,
|
|
64
|
+
name: 'warning-name',
|
|
65
|
+
message: 'There was a problem'
|
|
66
|
+
}]
|
|
67
|
+
}]
|
|
68
|
+
});
|
|
69
69
|
|
|
70
|
-
t.true((0, _lodash2.default)(
|
|
71
|
-
t.true((0, _lodash2.default)(
|
|
72
|
-
t.true((0, _lodash2.default)(
|
|
70
|
+
t.true((0, _lodash2.default)(actualError, 'There was an error'));
|
|
71
|
+
t.true((0, _lodash2.default)(actualError, '1 problems, 0 warnings'));
|
|
72
|
+
t.true((0, _lodash2.default)(actualWarning, 'There was a problem'));
|
|
73
|
+
t.true((0, _lodash2.default)(actualWarning, '0 problems, 1 warnings'));
|
|
73
74
|
});
|
|
74
75
|
|
|
75
76
|
(0, _ava2.default)('uses appropriate signs by default', t => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
level: 1,
|
|
84
|
-
name: 'warning-name',
|
|
85
|
-
message: 'There was a problem'
|
|
77
|
+
const actualError = (0, _2.default)({
|
|
78
|
+
results: [{
|
|
79
|
+
errors: [{
|
|
80
|
+
level: 2,
|
|
81
|
+
name: 'error-name',
|
|
82
|
+
message: 'There was an error'
|
|
83
|
+
}]
|
|
86
84
|
}]
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const actualWarning = (0, _2.default)({
|
|
88
|
+
results: [{
|
|
89
|
+
warnings: [{
|
|
90
|
+
level: 1,
|
|
91
|
+
name: 'warning-name',
|
|
92
|
+
message: 'There was a problem'
|
|
93
|
+
}]
|
|
94
|
+
}]
|
|
95
|
+
});
|
|
93
96
|
|
|
94
|
-
t.true((0, _lodash2.default)(
|
|
95
|
-
t.true((0, _lodash2.default)(
|
|
97
|
+
t.true((0, _lodash2.default)(actualError, '✖'));
|
|
98
|
+
t.true((0, _lodash2.default)(actualWarning, '⚠'));
|
|
96
99
|
});
|
|
97
100
|
|
|
98
101
|
(0, _ava2.default)('uses signs as configured', t => {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
name: 'warning-name',
|
|
108
|
-
message: 'There was a problem'
|
|
102
|
+
const options = { signs: ['HNT', 'WRN', 'ERR'] };
|
|
103
|
+
const actualError = (0, _2.default)({
|
|
104
|
+
results: [{
|
|
105
|
+
errors: [{
|
|
106
|
+
level: 2,
|
|
107
|
+
name: 'error-name',
|
|
108
|
+
message: 'There was an error'
|
|
109
|
+
}]
|
|
109
110
|
}]
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
111
|
+
}, options);
|
|
112
|
+
|
|
113
|
+
const actualWarning = (0, _2.default)({
|
|
114
|
+
results: [{
|
|
115
|
+
warnings: [{
|
|
116
|
+
level: 1,
|
|
117
|
+
name: 'warning-name',
|
|
118
|
+
message: 'There was a problem'
|
|
119
|
+
}]
|
|
120
|
+
}]
|
|
121
|
+
}, options);
|
|
118
122
|
|
|
119
|
-
t.true((0, _lodash2.default)(
|
|
120
|
-
t.true((0, _lodash2.default)(
|
|
123
|
+
t.true((0, _lodash2.default)(actualError, 'ERR'));
|
|
124
|
+
t.true((0, _lodash2.default)(actualWarning, 'WRN'));
|
|
121
125
|
});
|
|
122
126
|
//# sourceMappingURL=index.test.js.map
|
package/lib/index.test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.test.js"],"names":["ok","bold","green","t","actual","deepEqual","
|
|
1
|
+
{"version":3,"sources":["../src/index.test.js"],"names":["ok","bold","green","t","actual","deepEqual","results","errors","warnings","true","includes","actualError","level","name","message","actualWarning","options","signs"],"mappings":";;AAAA;;;;AACA;;;;AACA;;;;AACA;;;;;;AAEA,MAAMA,KAAK,gBAAMC,IAAN,CAAY,GAAE,gBAAMC,KAAN,CAAY,GAAZ,CAAiB,iCAA/B,CAAX;;AAEA,mBAAK,gCAAL,EAAuCC,KAAK;AAC3C,OAAMC,SAAS,iBAAf;AACAD,GAAEE,SAAF,CAAYD,MAAZ,EAAoBJ,EAApB;AACA,CAHD;;AAKA,mBAAK,qCAAL,EAA4CG,KAAK;AAChD,OAAMC,SAAS,gBAAO,EAACE,SAAS,EAAV,EAAP,CAAf;AACAH,GAAEE,SAAF,CAAYD,MAAZ,EAAoBJ,EAApB;AACA,CAHD;;AAKA,mBAAK,4CAAL,EAAmDG,KAAK;AACvD,OAAMC,SAAS,gBAAO,EAACE,SAAS,CAAC,EAAD,CAAV,EAAP,CAAf;AACAH,GAAEE,SAAF,CAAYD,MAAZ,EAAoBJ,EAApB;AACA,CAHD;;AAKA,mBAAK,mEAAL,EAA0EG,KAAK;AAC9E,OAAMC,SAAS,gBAAO;AACrBE,WAAS,CACR;AACCC,WAAQ,EADT;AAECC,aAAU;AAFX,GADQ;AADY,EAAP,CAAf;;AASAL,GAAEM,IAAF,CAAOL,OAAOM,QAAP,CAAgB,wBAAhB,CAAP;AACA,CAXD;;AAaA,mBAAK,kDAAL,EAAyDP,KAAK;AAC7D,OAAMQ,cAAc,gBAAO;AAC1BL,WAAS,CACR;AACCC,WAAQ,CACP;AACCK,WAAO,CADR;AAECC,UAAM,YAFP;AAGCC,aAAS;AAHV,IADO;AADT,GADQ;AADiB,EAAP,CAApB;;AAcA,OAAMC,gBAAgB,gBAAO;AAC5BT,WAAS,CACR;AACCE,aAAU,CACT;AACCI,WAAO,CADR;AAECC,UAAM,cAFP;AAGCC,aAAS;AAHV,IADS;AADX,GADQ;AADmB,EAAP,CAAtB;;AAcAX,GAAEM,I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;AACAR,GAAEM,IAAF,CAAO,sBAASM,aAAT,EAAwB,KAAxB,CAAP;AACA,CAtCD","file":"index.test.js","sourcesContent":["import test from 'ava';\nimport chalk from 'chalk';\nimport includes from 'lodash.includes';\nimport format from '.';\n\nconst ok = chalk.bold(`${chalk.green('✔')} found 0 problems, 0 warnings`);\n\ntest('does nothing without arguments', t => {\n\tconst actual = format();\n\tt.deepEqual(actual, ok);\n});\n\ntest('does nothing without report results', t => {\n\tconst actual = format({results: []});\n\tt.deepEqual(actual, ok);\n});\n\ntest('does nothing without .errors and .warnings', t => {\n\tconst actual = format({results: [{}]});\n\tt.deepEqual(actual, ok);\n});\n\ntest('returns empty summary of problems for empty .errors and .warnings', t => {\n\tconst actual = format({\n\t\tresults: [\n\t\t\t{\n\t\t\t\terrors: [],\n\t\t\t\twarnings: []\n\t\t\t}\n\t\t]\n\t});\n\n\tt.true(actual.includes('0 problems, 0 warnings'));\n});\n\ntest('returns a correct of empty .errors and .warnings', t => {\n\tconst actualError = format({\n\t\tresults: [\n\t\t\t{\n\t\t\t\terrors: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlevel: 2,\n\t\t\t\t\t\tname: 'error-name',\n\t\t\t\t\t\tmessage: 'There was an error'\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t});\n\n\tconst actualWarning = format({\n\t\tresults: [\n\t\t\t{\n\t\t\t\twarnings: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlevel: 1,\n\t\t\t\t\t\tname: 'warning-name',\n\t\t\t\t\t\tmessage: 'There was a problem'\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t});\n\n\tt.true(includes(actualError, 'There was an error'));\n\tt.true(includes(actualError, '1 problems, 0 warnings'));\n\tt.true(includes(actualWarning, 'There was a problem'));\n\tt.true(includes(actualWarning, '0 problems, 1 warnings'));\n});\n\ntest('uses appropriate signs by default', t => {\n\tconst actualError = format({\n\t\tresults: [\n\t\t\t{\n\t\t\t\terrors: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlevel: 2,\n\t\t\t\t\t\tname: 'error-name',\n\t\t\t\t\t\tmessage: 'There was an error'\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t});\n\n\tconst actualWarning = format({\n\t\tresults: [\n\t\t\t{\n\t\t\t\twarnings: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlevel: 1,\n\t\t\t\t\t\tname: 'warning-name',\n\t\t\t\t\t\tmessage: 'There was a problem'\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t});\n\n\tt.true(includes(actualError, '✖'));\n\tt.true(includes(actualWarning, '⚠'));\n});\n\ntest('uses signs as configured', t => {\n\tconst options = {signs: ['HNT', 'WRN', 'ERR']};\n\tconst actualError = format(\n\t\t{\n\t\t\tresults: [\n\t\t\t\t{\n\t\t\t\t\terrors: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlevel: 2,\n\t\t\t\t\t\t\tname: 'error-name',\n\t\t\t\t\t\t\tmessage: 'There was an error'\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\toptions\n\t);\n\n\tconst actualWarning = format(\n\t\t{\n\t\t\tresults: [\n\t\t\t\t{\n\t\t\t\t\twarnings: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlevel: 1,\n\t\t\t\t\t\t\tname: 'warning-name',\n\t\t\t\t\t\t\tmessage: 'There was a problem'\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\toptions\n\t);\n\n\tt.true(includes(actualError, 'ERR'));\n\tt.true(includes(actualWarning, 'WRN'));\n});\n"]}
|
package/license.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 - present Mario Nebl
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commitlint/format",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.1",
|
|
4
4
|
"description": "Format commitlint reports",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -59,11 +59,11 @@
|
|
|
59
59
|
},
|
|
60
60
|
"license": "MIT",
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@commitlint/test": "^7.
|
|
63
|
-
"@commitlint/utils": "^7.
|
|
62
|
+
"@commitlint/test": "^7.1.2",
|
|
63
|
+
"@commitlint/utils": "^7.1.2",
|
|
64
64
|
"ava": "0.22.0",
|
|
65
65
|
"babel-cli": "6.26.0",
|
|
66
|
-
"babel-preset-commitlint": "^7.
|
|
66
|
+
"babel-preset-commitlint": "^7.1.2",
|
|
67
67
|
"babel-register": "6.26.0",
|
|
68
68
|
"concurrently": "3.5.1",
|
|
69
69
|
"cross-env": "5.1.1",
|