Skip to content
Browse files

Update dist-tags properly

  • Loading branch information...
1 parent 337c376 commit f628ae309612e2e807bc21f356f78ff4d9fad088 @kriszyp committed Jan 6, 2011
Showing with 9 additions and 4 deletions.
  1. +9 −4 lib/model/package.js
View
13 lib/model/package.js
@@ -5,7 +5,7 @@ var Model = require("perstore/model").Model,
DefaultStore = require("perstore/stores").DefaultStore,
promiseModule = require("promised-io/promise"),
queryRepo = require("./git").queryRepo,
- host = require("commonjs-utils/settings").host,
+ host = require("commonjs-utils/settings").host || "/",
print = require("sys").puts,
httpClient = require("promised-io/http-client"),
when = promiseModule.when,
@@ -99,6 +99,7 @@ function updateVersions(pckg, force){
var repoName = repo.url.substring(repo.url.indexOf('/',10) + 1);
print(" querying repo " + repoName);
var packageUpdates = [];
+ var latestVersion;
return when(queryRepo(repoName).forEach(function(version, type){
print("add version " + version);
try{
@@ -107,9 +108,10 @@ function updateVersions(pckg, force){
// following semver v-prefixing for tags, strip it off
version = version.substring(1);
}
+ console.log("firstRepo " + firstRepo);
if(firstRepo && (!versions[version] || force)){
update();
- pckg["dist-tags"] = {"latest":version};
+ latestVersion = version;
}
var owner = repoName.substring(0, repoName.indexOf("/"));
version = owner + '-' + version;
@@ -162,8 +164,11 @@ function updateVersions(pckg, force){
}catch(e){
print("Error setting version " + e.stack);
}
- }), function(e){
- print("error " + e);
+ }), function(){
+ if(latestVersion && (!pckg["dist-tags"] || pckg["dist-tags"] != latestVersion)){
+ pckg["dist-tags"] = {"latest": latestVersion};
+ packageStore.put(pckg);
+ }
return all(packageUpdates);
});
});

0 comments on commit f628ae3

Please sign in to comment.
Something went wrong with that request. Please try again.