You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
851 B
23 lines
851 B
const { yellow, cyan } = require('colorette');
|
|
const logger = require('../utils/logger');
|
|
const { packageExists } = require('../utils/package-exists');
|
|
const { promptInstallation } = require('../utils/prompt-installation');
|
|
|
|
const packagePrefix = '@webpack-cli';
|
|
|
|
const run = async (name, ...args) => {
|
|
const scopeName = packagePrefix + '/' + name;
|
|
let pkgLoc = packageExists(scopeName);
|
|
if (!pkgLoc) {
|
|
try {
|
|
pkgLoc = await promptInstallation(`${scopeName}`, () => {
|
|
logger.error(`The command moved into a separate package: ${yellow(scopeName)}\n`);
|
|
});
|
|
} catch (err) {
|
|
logger.error(`Action Interrupted, use ${cyan('webpack-cli help')} to see possible commands.`);
|
|
}
|
|
}
|
|
return pkgLoc ? require(scopeName).default(...args) : null;
|
|
};
|
|
|
|
module.exports = run;
|
|
|