Skip to content

Commit ec868ef

Browse files
wtgtybhertgeghgtwtgmarionebl
authored andcommitted
chore: update dependency meow to v4.0.0 (#308)
1 parent b0bbce3 commit ec868ef

File tree

3 files changed

+77
-55
lines changed

3 files changed

+77
-55
lines changed

@commitlint/cli/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,6 @@
8484
"get-stdin": "5.0.1",
8585
"lodash.merge": "4.6.1",
8686
"lodash.pick": "4.4.0",
87-
"meow": "3.7.0"
87+
"meow": "4.0.0"
8888
}
8989
}

@commitlint/cli/src/cli.js

+67-45
Original file line numberDiff line numberDiff line change
@@ -14,58 +14,80 @@ const stdin = require('get-stdin');
1414
const pkg = require('../package');
1515
const help = require('./help');
1616

17-
const configuration = {
18-
string: ['cwd', 'from', 'to', 'edit', 'extends', 'parser-preset', 'config'],
19-
boolean: ['help', 'version', 'quiet', 'color'],
20-
alias: {
21-
c: 'color',
22-
d: 'cwd',
23-
e: 'edit',
24-
f: 'from',
25-
t: 'to',
26-
q: 'quiet',
27-
h: 'help',
28-
g: 'config',
29-
v: 'version',
30-
x: 'extends',
31-
p: 'parser-preset'
17+
const flags = {
18+
color: {
19+
alias: 'c',
20+
default: true,
21+
description: 'toggle colored output',
22+
type: 'boolean'
3223
},
33-
description: {
34-
color: 'toggle colored output',
35-
cwd: 'directory to execute in',
36-
config: 'path to the config file',
37-
edit:
24+
config: {
25+
alias: 'g',
26+
default: null,
27+
description: 'path to the config file',
28+
type: 'string'
29+
},
30+
cwd: {
31+
alias: 'd',
32+
default: process.cwd(),
33+
description: 'directory to execute in',
34+
type: 'string'
35+
},
36+
edit: {
37+
alias: 'e',
38+
default: false,
39+
description:
3840
'read last commit message from the specified file or fallbacks to ./.git/COMMIT_EDITMSG',
39-
extends: 'array of shareable configurations to extend',
40-
from: 'lower end of the commit range to lint; applies if edit=false',
41-
to: 'upper end of the commit range to lint; applies if edit=false',
42-
quiet: 'toggle console output',
43-
'parser-preset':
44-
'configuration preset to use for conventional-commits-parser'
41+
type: 'string'
4542
},
46-
default: {
47-
color: true,
48-
cwd: process.cwd(),
49-
config: null,
50-
edit: false,
51-
from: null,
52-
to: null,
53-
quiet: false
43+
extends: {
44+
alias: 'x',
45+
description: 'array of shareable configurations to extend',
46+
type: 'string'
5447
},
55-
unknown(arg) {
56-
throw new Error(`unknown flags: ${arg}`);
48+
help: {
49+
alias: 'h',
50+
type: 'boolean'
51+
},
52+
from: {
53+
alias: 'f',
54+
default: null,
55+
description: 'lower end of the commit range to lint; applies if edit=false',
56+
type: 'string'
57+
},
58+
'parser-preset': {
59+
alias: 'p',
60+
description: 'configuration preset to use for conventional-commits-parser',
61+
type: 'string'
62+
},
63+
quiet: {
64+
alias: 'q',
65+
default: false,
66+
description: 'toggle console output',
67+
type: 'boolean'
68+
},
69+
to: {
70+
alias: 't',
71+
default: null,
72+
description: 'upper end of the commit range to lint; applies if edit=false',
73+
type: 'string'
74+
},
75+
version: {
76+
alias: 'v',
77+
type: 'boolean'
5778
}
5879
};
5980

60-
const cli = meow(
61-
{
62-
help: `[input] reads from stdin if --edit, --from and --to are omitted\n${help(
63-
configuration
64-
)}`,
65-
description: `${pkg.name}@${pkg.version} - ${pkg.description}`
66-
},
67-
configuration
68-
);
81+
const cli = meow({
82+
description: `${pkg.name}@${pkg.version} - ${pkg.description}`,
83+
flags,
84+
help: `[input] reads from stdin if --edit, --from and --to are omitted\n${help(
85+
flags
86+
)}`,
87+
unknown(arg) {
88+
throw new Error(`unknown flags: ${arg}`);
89+
}
90+
});
6991

7092
main(cli).catch(err =>
7193
setTimeout(() => {

@commitlint/cli/src/help.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
module.exports = configuration => {
2-
const lines = Object.entries(configuration.description).map(entry => {
1+
module.exports = flags => {
2+
const lines = Object.entries(flags).map(entry => {
33
const name = entry[0];
4-
const desc = entry[1];
5-
const alias = Object.entries(configuration.alias)
6-
.find(entry => entry[1] === name)
7-
.map(entry => entry[0])[0];
8-
const defaults = configuration.default[name];
9-
return [[name, alias].filter(Boolean), desc, defaults].filter(Boolean);
4+
const value = entry[1];
5+
return [
6+
[name, value.alias].filter(Boolean),
7+
value.description,
8+
value.default
9+
].filter(Boolean);
1010
});
1111

1212
const longest = lines
1313
.map(line => {
1414
const flags = line[0];
1515
return flags.reduce((sum, flag) => sum + flag.length, 0);
1616
})
17-
.sort(Number)[0];
17+
.sort((a, b) => b - a)[0];
1818

1919
return lines
2020
.map(line => {

0 commit comments

Comments
 (0)