MCPcopy Index your code
hub / github.com/loopbackio/loopback-next / runCommand

Function runCommand

packages/cli/lib/cli.js:24–49  ·  view source on GitHub ↗

* Parse arguments and run corresponding command * @param env - Yeoman env * @param {*} opts Command options * @param log - Log function

(env, opts, log)

Source from the content-addressed store, hash-verified

22 * @param log - Log function
23 */
24function 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

Callers 1

mainFunction · 0.85

Calls 2

printCommandsFunction · 0.85
runMethod · 0.45

Tested by

no test coverage detected