UNPKG

@storm-stack/core

Version:

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

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