Skip to content

Commit 17f6d7b

Browse files
committed
fix(cli): 修复自定义命令没有缩写会造成 help 命令报错
1 parent 9036cbc commit 17f6d7b

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/cli.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ var cli = module.exports = {
5656
help: function help() {
5757
info(helpTitle);
5858
Manager.getProject(process.cwd()).commands.forEach(function (command) {
59-
info(' ' + rightPad(command.name, 8) + ' ' + rightPad(command.abbr, 26) + ' # ' + (command.module.usage || ''));
59+
var commandStr = rightPad(rightPad(command.name, 8) + (command.abbr || ''), 35);
60+
info(' ' + commandStr + ' # ' + (command.module.usage || ''));
6061
});
6162
info();
6263
info(' 可用的全局配置有:', (Manager.readRC().configs || []).map(function (item) {

src/cli.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ let cli = module.exports = {
5454
help: () => {
5555
info(helpTitle);
5656
Manager.getProject(process.cwd()).commands.forEach((command) => {
57-
info(` ${rightPad(command.name, 8)} ${rightPad(command.abbr, 26)} # ${command.module.usage || ''}`);
57+
const commandStr = rightPad(rightPad(command.name, 8) + (command.abbr || ''), 35)
58+
info(` ${commandStr} # ${command.module.usage || ''}`);
5859
});
5960
info();
6061
info(' 可用的全局配置有:', (Manager.readRC().configs || []).map((item) => item.name.substring(12)).join(', '));

0 commit comments

Comments
 (0)