Skip to content
This repository
Browse code

Merge branch 'master' of github.com:component/component

  • Loading branch information...
commit aa7c059c4071418a81ea7607845d9af440e43ed8 2 parents 991568e + c86f69a
TJ Holowaychuk authored January 17, 2013
19  bin/component-install
@@ -94,7 +94,8 @@ if (local) {
94 94
 if (!local) {
95 95
   conf.dependencies = conf.dependencies || {};
96 96
   pkgs.forEach(function(pkg){
97  
-    conf.dependencies[pkg] = '*';
  97
+    pkg = parsePackage(pkg);
  98
+    conf.dependencies[pkg.name] = pkg.version || '*';
98 99
   });
99 100
   saveConfig();
100 101
 }
@@ -108,12 +109,20 @@ conf.remotes.push('https://raw.github.com');
108 109
 
109 110
 console.log();
110 111
 pkgs.forEach(function(pkg){
111  
-  var parts = pkg.split('@');
112  
-  var name = parts.shift();
113  
-  var version = parts.shift() || 'master';
114  
-  install(name, version);
  112
+  pkg = parsePackage(pkg);
  113
+  install(pkg.name, pkg.version || 'master');
115 114
 });
116 115
 
  116
+// parse package identifier
  117
+
  118
+function parsePackage(pkg) {
  119
+  var parts = pkg.split('@');
  120
+  return {
  121
+    name: parts.shift(),
  122
+    version: parts.shift()
  123
+  };
  124
+}
  125
+
117 126
 // map deps to args
118 127
 
119 128
 function normalize(deps) {
6  test/install.js
@@ -40,10 +40,10 @@ describe('component install', function(){
40 40
     })
41 41
 
42 42
     it('should add the component to ./component.json', function(done){
43  
-      exec('bin/component install component/emitter', function(err, stdout){
  43
+      exec('bin/component install component/emitter@0.0.4', function(err, stdout){
44 44
         if (err) return done(err);
45 45
         var json = require(path.resolve('component.json'));
46  
-        json.dependencies.should.have.property('component/emitter', '*');
  46
+        json.dependencies.should.have.property('component/emitter', '0.0.4');
47 47
         done();
48 48
       })
49 49
     })
@@ -126,4 +126,4 @@ describe('component install', function(){
126 126
       done();
127 127
     })
128 128
   })
129  
-})
  129
+})

0 notes on commit aa7c059

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