Skip to content

Commit

Permalink
refactor: remove debug snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 committed Jun 29, 2020
1 parent 57b21e5 commit 1ef9f7f
Showing 1 changed file with 3 additions and 34 deletions.
37 changes: 3 additions & 34 deletions packages/webpack-cli/lib/utils/arg-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ function argParser(options, args, argsOnly = false, name = '', helpFunction = un
// Set parser name
parser.name(name);

let commandNames = [];
let commandAliases = [];

if (commands) {
commands.reduce((parserInstance, cmd) => {
parser
Expand All @@ -36,39 +33,11 @@ function argParser(options, args, argsOnly = false, name = '', helpFunction = un
.usage(cmd.usage)
.allowUnknownOption(true)
.action(async () => {
return await require('../commands/ExternalCommand').run(
defaultCommands[cmd.name],
...args.slice(args.indexOf(cmd.name) + 1 || args.indexOf(cmd.alias) + 1),
);
const cliArgs = args.slice(args.indexOf(cmd.name) + 1 || args.indexOf(cmd.alias) + 1);
return await require('../commands/ExternalCommand').run(defaultCommands[cmd.name], ...cliArgs);
});
// if (cmd.flags) {
// cmd.flags.forEach((subCmdFlag) => {
// parser.commands.forEach((parsedArgs) => {
// const cliFlag = subCmdFlag.type === Boolean ? subCmdFlag.name : `--${subCmdFlag.name} <value>`
// const option = {
// flags: cliFlag,
// // required: true,
// // optional: false,
// // mandatory: false,
// // negate: false,
// // short: subCmdFlag.alias,
// // long: subCmdFlag.name,
// description: subCmdFlag.description,
// defaultValue: subCmdFlag.defaultValue,
// };
// if (parsedArgs._name === cmd.name) {
// parsedArgs.options.push(option);
// parsedArgs._actionHandler = ((option) => require('../commands/ExternalCommand').run(defaultCommands[cmd.name], option));
// console.log(parsedArgs)
// return;
// }
// });
// });
// }
return parser;
}, parser);
commandNames = commands.map((cmd) => cmd.name);
commandAliases = commands.map((cmd) => cmd.alias);

// Prevent default behavior
parser.on('command:*', () => {});
Expand Down Expand Up @@ -130,7 +99,7 @@ function argParser(options, args, argsOnly = false, name = '', helpFunction = un
const result = parser.parse(args, parseOptions);
const opts = result.opts();

const unknownArgs = commands ? result.args.filter((arg) => !commandNames.includes(arg) && !commandAliases.includes(arg)) : result.args;
const unknownArgs = result.args;

args.forEach((arg) => {
const flagName = arg.slice(5);
Expand Down

0 comments on commit 1ef9f7f

Please sign in to comment.