mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
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:
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user