Merge pull request #10963 from meteor/fix-first-time-cordova-lib-installation

Stop calling moduleDoesResolve before installing Cordova npm deps.
This commit is contained in:
Filipe Névola
2020-03-11 22:52:44 -03:00
committed by GitHub
2 changed files with 12 additions and 21 deletions

View File

@@ -1,20 +1,25 @@
import { pathJoin, getDevBundle } from '../fs/files';
import { installNpmModule, moduleDoesResolve } from '../isobuild/meteor-npm.js';
import { pathJoin, getDevBundle, statOrNull } from '../fs/files';
import { installNpmModule } from '../isobuild/meteor-npm.js';
export 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 => {
if (!moduleDoesResolve(dep)) {
const pkgDir = pathJoin(devBundleNodeModules, dep);
const pkgStat = statOrNull(pkgDir);
const alreadyInstalled = pkgStat && pkgStat.isDirectory();
if (!alreadyInstalled) {
const versionToInstall = deps[dep];
needToInstall[dep] = versionToInstall;
}
});
const devBundleLib = pathJoin(getDevBundle(), 'lib');
// Install each of the requested modules.
Object.keys(needToInstall)
.forEach(dep => installNpmModule(dep, needToInstall[dep], devBundleLib));
Object.keys(needToInstall).forEach(dep => {
installNpmModule(dep, needToInstall[dep], devBundleLib);
});
}

View File

@@ -1053,20 +1053,6 @@ var getShrinkwrappedDependencies = function (dir) {
return treeToDependencies(getShrinkwrappedDependenciesTree(dir));
};
const moduleDoesResolve = meteorNpm.moduleDoesResolve = (dep) => {
try {
require.resolve(dep);
} catch (e) {
if (e.code !== 'MODULE_NOT_FOUND') {
throw e;
}
return false;
}
return true;
};
const installNpmModule = meteorNpm.installNpmModule = (name, version, dir) => {
const installArg = utils.isNpmUrl(version)
? version