Skip to content

Commit

Permalink
log build errors, version lookup adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Oct 24, 2014
1 parent cdb155b commit d37cef6
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions lib/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ exports.getVersionMatch = function(pkg, versions) {
versionList.push(v);
}

branchVersions.sort(semver.compare);
versionList.sort(semver.compare);
branchVersions.sort(semver.compare).reverse();
versionList.sort(semver.compare).reverse();

// find highest stable match in tags
for (var i = versionList.length - 1; i >=0; i--) {
for (var i = 0; i < versionList.length; i++) {
var version = versionList[i];

var semverMatch = version.match(semver.semverRegEx);
Expand Down Expand Up @@ -279,7 +279,7 @@ exports.download = function(pkg, jspmPackages, options, preload) {

var downloadDir = path.resolve(jspmPackages, pkg.endpoint, pkg.exactPackage);
var cacheDir = path.resolve(config.HOME, '.jspm', 'packages', pkg.endpoint, pkg.exactPackage);
var exactVersion, lastNamePart, main;
var lastNamePart, main;

var override;

Expand All @@ -290,9 +290,6 @@ exports.download = function(pkg, jspmPackages, options, preload) {
var endpoint = ep.load(pkg.endpoint);

return Promise.resolve()
.then(function() {
exactVersion = pkg.version;
})

// get the override
.then(function() {
Expand Down Expand Up @@ -377,7 +374,7 @@ exports.download = function(pkg, jspmPackages, options, preload) {
if (endpoint.getPackageConfig)
// we only use the getPackageConfig pjson if
// we are going to run a build, otherwise we use the saved one
return Promise.resolve(endpoint.getPackageConfig(pkg.package, exactVersion, pkg.hash))
return Promise.resolve(endpoint.getPackageConfig(pkg.package, pkg.version, pkg.hash))
.then(function(_pjson) {
// apply the override and package config operations
if (!pjson)
Expand Down Expand Up @@ -408,7 +405,7 @@ exports.download = function(pkg, jspmPackages, options, preload) {
})
// do the download
.then(function() {
return endpoint.download(pkg.package, exactVersion, pkg.hash, cacheDir);
return endpoint.download(pkg.package, pkg.version, pkg.hash, cacheDir);
})

// process the package fully
Expand Down Expand Up @@ -466,6 +463,7 @@ exports.download = function(pkg, jspmPackages, options, preload) {
exports.processPackage = function(pkg, dir, pjson) {
var endpoint = ep.load(pkg.endpoint);
var deps;
var buildErrors = [];

return Promise.resolve()

Expand All @@ -476,16 +474,28 @@ exports.processPackage = function(pkg, dir, pjson) {
})

// apply build operations from the package.json
.then(function() {
.then(function(_buildErrors) {
if (_buildErrors)
buildErrors = buildErrors.concat(_buildErrors);

// don't build in dependencies
deps = pjson.dependencies;
delete pjson.dependencies;
return build.buildPackage(dir, pjson);
})

// save the final calculated package.json in place
.then(function() {
.then(function(_buildErrors) {
if (_buildErrors)
buildErrors = buildErrors.concat(_buildErrors);
pjson.dependencies = deps;
})
.then(function() {
// write build errors
if (buildErrors.length)
return asp(fs.writeFile)(path.resolve(dir, '.jspm.errors'), buildErrors.join('\n\n'));
})
.then(function() {
return asp(fs.writeFile)(path.resolve(dir, '.jspm.json'), JSON.stringify(pjson, null, 2));
});
}
Expand Down

0 comments on commit d37cef6

Please sign in to comment.