Skip to content

Commit 51af1e1

Browse files
committed
chore: use Object.keys in commands
1 parent 3edee26 commit 51af1e1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/utils/commands.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
const arguments = require('./cli-flags');
22

3-
const names = [];
4-
arguments.commands.forEach( command => {
5-
names.push(command.name);
6-
if (command.alias) names.push(command.alias);
7-
})
3+
const info = arguments.commands;
4+
const names = Object.keys(info).map( i => {
5+
if (info[i].alias) {
6+
return [info[i].name, info[i].alias];
7+
}
8+
return [info[i].name];
9+
}).reduce((arr, val) => arr.concat(val), []);
810

911
module.exports.names = names;
1012
module.exports.info = arguments.commands;

0 commit comments

Comments
 (0)