make package-loader take null version argument for local packages only

This commit is contained in:
ekatek
2014-03-12 14:56:08 -07:00
parent 806b740a6b
commit a8788a8084
3 changed files with 21 additions and 12 deletions

View File

@@ -252,12 +252,16 @@ _.extend(Catalog.prototype, {
//
// Doesn't download packages. Downloading should be done at the time
// that .meteor/versions is updated.
//
// HACK: Version can be null if you are certain that the package is to be
// loaded from local packages. In the future, version should always be
// required and we should confirm that the version on disk is the version that
// we asked for. This is to support unipackage loader not having a version
// manifest.
getLoadPathForPackage: function (name, version) {
var self = this;
if (_.has(self.effectiveLocalPackages, name)) {
// XXX should confirm that the version on disk actually matches
// the requested version
return self.effectiveLocalPackages[name];
}

View File

@@ -5,7 +5,8 @@ var catalog = require('./catalog.js');
var packageLoader = exports;
// options:
// versions: a map from package name to the version to use
// - versions: a map from package name to the version to use. or null to only
// use local packages and ignore the package versions.
packageLoader.PackageLoader = function (options) {
var self = this;
self.versions = options.versions;
@@ -37,11 +38,17 @@ _.extend(packageLoader.PackageLoader, {
options.throwOnError = true;
}
if (! _.has(self.versions, name))
if (! self.versions && ! _.has(self.versions, name))
throw new Error("no version chosen for package?");
var loadPath = catalog.getLoadPathForPackage(name,
self.versions[name]);
var version;
if (self.versions) {
version = self.versions[name];
} else {
version = null;
}
var loadPath = catalog.getLoadPathForPackage(name, version);
if (! loadPath) {
if (options.throwOnError === false)
return null;
@@ -72,5 +79,5 @@ _.extend(packageLoader.PackageLoader, {
return [pkg.getSingleSlice(spec.slice, arch)];
else
return pkg.getDefaultSlices(arch);
},
}
});

View File

@@ -3,7 +3,7 @@ var library = require('./library.js');
var bundler = require('./bundler.js');
var buildmessage = require('./buildmessage.js');
var release = require('./release.js');
var PackageLoader = require("./package-loader.js");
var PackageLoader = require("./package-loader.js").PackageLoader;
var packageCache = require("./package-cache.js");
// Load unipackages into the currently running node.js process. Use
@@ -80,10 +80,8 @@ var load = function (options) {
title: "loading unipackage"
}, function () {
// Load the code
// #RunningTheConstraintSolverToBuildAPackage ???
var versions = { }; // XXX XXX actually run the constraint solver!
var loader = new PackageLoader.PackageLoader({
versions: versions
var loader = new PackageLoader({
versions: null
});
var image = bundler.buildJsImage({