1 | /**
|
2 | * 将 cmd 中的选项参数的值提取成一个新对象
|
3 | */
|
4 | module.exports = function cleanArgs(cmd) {
|
5 | const args = {};
|
6 | if (!cmd || !cmd.options) {
|
7 | return args;
|
8 | }
|
9 | cmd.options.forEach((option) => {
|
10 | const key = option.long.replace(/^--/, '');
|
11 | if (typeof cmd[key] !== 'function' && typeof cmd[key] !== 'undefined') {
|
12 | args[key] = cmd[key];
|
13 | }
|
14 | });
|
15 | return args;
|
16 | };
|