Permalink
Browse files

Fix NPM package submission

  • Loading branch information...
1 parent 05b9fa9 commit 2a0b98c4e701aec61ec68a5983f8f1d85dc1ec0b @kriszyp committed Jul 1, 2011
Showing with 13 additions and 5 deletions.
  1. +13 −5 lib/model/package.js
View
@@ -21,9 +21,17 @@ PackageModel = exports.Package = Model(packageStore, {
var url = typeof object == "string" ? object : object.url;
return when(publish(url, undefined, true), function(packageData){
if(object.npm){
- packageData._id = packageData.name;
- var npmResponse = request({url:"http://registry.npmjs.org/" + packageData.name, method:"POST", body:
- JSON.stringify(packageData)
+ if(!packageData.maintainers){
+ throw new Error("A list of maintainers must be provided");
+ }
+ var redirectUrl = "http://packages.dojofoundation.org/" + packageData.name;
+ packageData.url = redirectUrl;
+ packageData.location = redirectUrl;
+ var npmResponse = request({
+ url:"http://registry.npmjs.org/" + packageData.name,
+ method:"PUT",
+ headers: {"content-type": "application/json"},
+ body: [JSON.stringify(packageData)]
});
}else{
var npmResponse = {status: 200};
@@ -223,7 +231,7 @@ function publish(url, asName, force){
/*if(asName && notPublishedAsName){
linkToExistingPackage();
}*/
- return asName;
+ return isAlreadyPublished;
}
if(url.match(/github/)){
require("sys").puts("url" + url);
@@ -278,7 +286,7 @@ function publish(url, asName, force){
});
}
packageStore.put(pckg);
- return packageData.name;
+ return packageData;
});
}

0 comments on commit 2a0b98c

Please sign in to comment.