Files
meteor/tools/cli/dev-bundle-helpers.js
Jesse Rosenberger 26f5ce1833 Introduce Cordova ensureDevBundleDependencies.
This Cordova `ensureDevBundleDependencies` function will utilize a another
method called `ensureDependencies` which checks to see if a module can be
resolved by the tool.  If it cannot be resolved, it will install it using the
`installNpmModule` facilities of `meteor-npm.js` in the same way as other npm
packages within packages, except with the destination as the `dev_bundle`.

This commit also adds a couple of previously not explicitly installed npm
modules which Meteor requires directly: `cordova-registry-mapper` and
`cordova-common`.  Both of these were previously relying on npm package hoisting
which previously occurred during the installation of `cordova-lib` in the dev
bundle which happened under the supervision of a `package.json` file (which is
later purged).

When `cordova-lib` is installed directly, without a package.json, the
aforementioned packages are not hoisted to the top level, but instead reside
inside `cordova-lib`.  This is less than ideal since we're relying on the API
of an indirect dependency of `cordova-lib`.
2017-08-02 17:19:42 +03:00

21 lines
708 B
JavaScript

import { pathJoin, getDevBundle } from '../fs/files.js';
import { installNpmModule, moduleDoesResolve } from '../isobuild/meteor-npm.js';
export function ensureDependencies(deps) {
// 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 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));
}