* Parse arguments and run corresponding command * @param env - Yeoman env * @param {*} opts Command options * @param log - Log function
(env, opts, log)
| 22 | * @param log - Log function |
| 23 | */ |
| 24 | function runCommand(env, opts, log) { |
| 25 | const dryRun = opts.dryRun || opts['dry-run']; |
| 26 | const args = opts._; |
| 27 | const originalCommand = args.shift(); |
| 28 | let command = PREFIX + (originalCommand || 'app'); |
| 29 | const supportedCommands = env.getGeneratorsMeta(); |
| 30 | if (!(command in supportedCommands)) { |
| 31 | command = PREFIX + 'app'; |
| 32 | args.unshift(originalCommand); |
| 33 | args.unshift(command); |
| 34 | } else { |
| 35 | args.unshift(command); |
| 36 | } |
| 37 | debug('invoking generator', args); |
| 38 | // `yo` is adding flags converted to CamelCase |
| 39 | const options = camelCaseKeys(opts, {exclude: ['--', /^\w$/, 'argv']}); |
| 40 | Object.assign(options, opts); |
| 41 | debug('env.run %j %j', args, options); |
| 42 | if (!dryRun) { |
| 43 | env.run(args, options); |
| 44 | } |
| 45 | // list generators |
| 46 | if (opts.help && !originalCommand) { |
| 47 | printCommands(env, log); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Set up yeoman generators |
no test coverage detected