mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
- Start changing the meteor run command now. It's throwing errors when trying to check constraints/package-versions.
26 lines
942 B
JavaScript
26 lines
942 B
JavaScript
import { pathJoin, getDevBundle, statOrNull } from '../fs/files';
|
|
import { installNpmModule } from '../isobuild/meteor-npm.js';
|
|
|
|
export async function ensureDependencies(deps) {
|
|
const devBundleLib = pathJoin(getDevBundle(), 'lib');
|
|
const devBundleNodeModules = pathJoin(devBundleLib, 'node_modules');
|
|
|
|
// Check if each of the requested dependencies resolves, if not
|
|
// mark them for installation.
|
|
const needToInstall = Object.create(null);
|
|
Object.keys(deps).forEach(dep => {
|
|
const pkgDir = pathJoin(devBundleNodeModules, dep);
|
|
const pkgStat = statOrNull(pkgDir);
|
|
const alreadyInstalled = pkgStat && pkgStat.isDirectory();
|
|
if (!alreadyInstalled) {
|
|
const versionToInstall = deps[dep];
|
|
needToInstall[dep] = versionToInstall;
|
|
}
|
|
});
|
|
|
|
// Install each of the requested modules.
|
|
for (const dep of Object.keys(needToInstall)) {
|
|
await installNpmModule(dep, needToInstall[dep], devBundleLib);
|
|
}
|
|
}
|