UNPKG

@storm-stack/core

Version:

A build toolkit and runtime used by Storm Software in TypeScript applications

33 lines (31 loc) 1.53 kB
import { __name } from './chunk-43IZMM3W.js'; import { LogLevelLabel } from '@storm-software/config-tools/types'; import { install } from '@stryke/fs/install'; import { isPackageListed } from '@stryke/fs/package-fns'; import { isNumber } from '@stryke/type-checks/is-number'; async function installPackage(context, packageName, dev = false) { const isInstalled = await isPackageListed(packageName, context.options.projectRoot); if (!isInstalled) { if (context.options.skipInstalls !== true) { context.log(LogLevelLabel.WARN, `The package "${packageName}" is not installed. It will be installed automatically.`); const result = await install(packageName, { cwd: context.options.projectRoot, dev }); if (isNumber(result.exitCode) && result.exitCode > 0) { context.log(LogLevelLabel.ERROR, result.stderr); throw new Error(`An error occurred while installing the package "${packageName}"`); } } else { context.log(LogLevelLabel.WARN, `The package "${packageName}" is not installed. Since the "skipInstalls" option is set to true, it will not be installed automatically.`); } } } __name(installPackage, "installPackage"); async function installPackages(context, packages) { return Promise.all(packages.map(async (pkg) => installPackage(context, pkg.name, pkg.dev))); } __name(installPackages, "installPackages"); export { installPackage, installPackages }; //# sourceMappingURL=chunk-R43J2D55.js.map //# sourceMappingURL=chunk-R43J2D55.js.map