MCPcopy
hub / github.com/webpack/webpack / runCli

Function runCli

bin/webpack.js:81–99  ·  view source on GitHub ↗
(cli)

Source from the content-addressed store, hash-verified

79 * @returns {void}
80 */
81const runCli = (cli) => {
82 const path = require("path");
83
84 const pkgPath = require.resolve(`${cli.package}/package.json`);
85
86 /** @type {Record<string, EXPECTED_ANY> & { type: string, bin: Record<string, string> }} */
87 const pkg = require(pkgPath);
88
89 if (pkg.type === "module" || /\.mjs/i.test(pkg.bin[cli.binName])) {
90 import(path.resolve(path.dirname(pkgPath), pkg.bin[cli.binName])).catch(
91 (err) => {
92 console.error(err);
93 process.exitCode = 1;
94 }
95 );
96 } else {
97 require(path.resolve(path.dirname(pkgPath), pkg.bin[cli.binName]));
98 }
99};
100
101/**
102 * @typedef {object} CliOption

Callers 1

webpack.jsFile · 0.85

Calls 4

resolveMethod · 0.65
requireFunction · 0.50
testMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected