Skip to content

Instantly share code, notes, and snippets.

@dvv
Created November 15, 2010 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvv/700409 to your computer and use it in GitHub Desktop.
Save dvv/700409 to your computer and use it in GitHub Desktop.
diff --git a/lib/nodules.js b/lib/nodules.js
index f95fadb..2853901 100644
--- a/lib/nodules.js
+++ b/lib/nodules.js
@@ -679,6 +679,7 @@ exports.protocols = {
var exclamationIndex = uri.indexOf("!");
var target = uri.substring(exclamationIndex + 2);
var targetContents;
+ var origUri = uri;
uri = uri.substring(0, exclamationIndex);
return when(fs.stat(cachePath(uri)), function(stat){
if(!stat.mtime){
@@ -688,6 +689,25 @@ exports.protocols = {
return null;
}, onError);
function onError(){
+ if (uri.match(/\/zipball\/master$/)) {
+ // try Git
+ // TODO: a cmdline option?
+ var gitUri = uri.split('/').slice(1,5).join('/') + '.git';
+ var path = cachePath(uri);
+ ensurePath(path);
+ //console.log('TRYGIT', origUri, gitUri, path);
+ var exec = require('child_process').exec;
+ var deferred = promiseModule.defer();
+ var child = exec('git1 clone https:/' + gitUri + ' ' + path, function(err, stdout, stderr){
+ console.log('GITRES', err);
+ if (err) {
+ // TODO: fallback to following return when(...)
+ }
+ var fileName = origUri.replace(/.*!/, path);
+ deferred.resolve(readModuleFile(fileName, 'jar:' + uri));
+ });
+ return deferred.promise;
+ }
return when(getUri(uri), function(source){
if(source === null){
throw new Error("Archive not found " + uri);
@dvv
Copy link
Author

dvv commented Nov 16, 2010

L26 -- s/git1/git -- express failure used for test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment