require('shelljs/global');

var installBundle = function(gitPath) {
  gitPath = gitPath.trim().replace(/#.*/, '');
  if(!gitPath) { return; }
  var repoName = gitPath.replace(/.*\//, '');
  if(exec('git clone https://github.com/'+gitPath+'.git bundle/'+repoName).code != 0) {
    echo('Checkout failed for bundle '+gitPath);
    exit(1);
  }
};

cat('vimrc.bundles').split(/\r?\n/g).forEach(installBundle);
@@ -25,29 +25,35 @@
 );%0A%0Avar 
-installBundle
+repoNameFromGitPath
  = funct
@@ -73,17 +73,14 @@
 %7B%0A  
-gitPath =
+return
  git
@@ -88,15 +88,8 @@
 ath.
-trim().
 repl
@@ -97,19 +97,20 @@
 ce(/
-#
 .*
+%5C/
 /, '');%0A
   if
@@ -109,34 +109,51 @@
 ');%0A
-  if(!gitPath) %7B return; %7D
+%7D;%0A%0Avar installBundle = function(gitPath) %7B
 %0A  v
@@ -277,16 +277,17 @@
 .code !=
+=
  0) %7B%0A  
@@ -354,16 +354,533 @@
   %7D%0A%7D;%0A%0A
+var updateBundle = function(gitPath) %7B%0A  var repoName = repoNameFromGitPath(gitPath);%0A  pushd('bundle/' + repoName);%0A  if(exec('git pull').code !== 0) %7B%0A    echo('Update failed for bundle ' + gitPath);%0A    exit(1);%0A  %7D%0A  popd();%0A%7D;%0A%0Avar installOrUpdateBundle = function(gitPath) %7B%0A  gitPath = gitPath.trim().replace(/#.*/, '');%0A  if(!gitPath) %7B return; %7D%0A  var repoName = repoNameFromGitPath(gitPath);%0A  if(test('-d', 'bundle/' + repoName)) %7B%0A    updateBundle(gitPath);%0A  %7D else %7B%0A    installBundle(gitPath);%0A  %7D%0A%7D;%0A%0A
 cat('vim
@@ -927,12 +927,20 @@
 tall
+OrUpdate
 Bundle);
@@ -939,8 +939,9 @@
 Bundle);
+%0A

Update bundle if already installed