Permalink
Browse files

Fix path dependency issues

  • Loading branch information...
1 parent a02c8b6 commit a2f304107b1719529ddcb0817e9d644eb02c15b6 Bret Little committed Nov 14, 2012
Showing with 112 additions and 5 deletions.
  1. +9 −4 bower-installer
  2. +65 −0 bower-installer.js
  3. +1 −1 package.json
  4. +37 −0 test/component.json
View
@@ -6,9 +6,14 @@ var colors = require('colors');
var bower = require('bower');
var fs = require('fs');
var path = require('path');
-var cfg = require(path.join(__dirname, '..', '..','component.json')).install;
+var basePath = process.cwd();
+var cfg = require(path.join(basePath,'component.json')).install;
-var installPath = new File('../../' + cfg.path);
+if(!cfg || !cfg.path) {
+ console.log(("bower-installer error").red + " component.json must contain a valid install path");
+}
+
+var installPath = new File(basePath + '/' + cfg.path);
var installDependency = function(deps, key) {
@@ -21,8 +26,8 @@ var installDependency = function(deps, key) {
_.each(deps, function(dep) {
var f_s = dep;
- var f = new File( '../../' + f_s );
- var f_path = '../../' + cfg.path + '/' + f.getName();
+ var f = new File( basePath + '/' + f_s );
+ var f_path = basePath + '/' + cfg.path + '/' + f.getName();
f.copy( f_path, function(error, copied) {
if(!error && copied) {
View
@@ -0,0 +1,65 @@
+#!/usr/bin/env node
+
+var _ = require('lodash');
+var File = require('file-utils').File;
+var colors = require('colors');
+var bower = require('bower');
+var fs = require('fs');
+var path = require('path');
+var basePath = process.cwd();
+var cfg = require(path.join(basePath,'component.json')).install;
+
+if(!cfg || !cfg.path) {
+ console.log(("bower-installer error").red + " component.json must contain a valid install path");
+}
+
+var installPath = new File(basePath + '/' + cfg.path);
+
+var installDependency = function(deps, key) {
+
+ deps = cfg.sources && cfg.sources[key] ? cfg.sources[key] : deps;
+
+ if(!_.isArray(deps)) {
+ deps = [ deps ];
+ }
+
+ _.each(deps, function(dep) {
+
+ var f_s = dep;
+ var f = new File( basePath + '/' + f_s );
+ var f_path = basePath + '/' + cfg.path + '/' + f.getName();
+
+ f.copy( f_path, function(error, copied) {
+ if(!error && copied) {
+ console.log(('\t' + key + ' : ' + f_path).green);
+ } else {
+ console.log(('Error\t' + dep + ' : ' + f_path).red);
+ console.log('\t\t' + error);
+ }
+ });
+
+ });
+};
+
+installPath.remove(function() {
+ installPath.createDirectory();
+});
+
+bower.commands
+ .list({paths: true})
+ .on('data', function (data) {
+ console.log('Installing: ');
+
+ _.each(data, function(dep, key) {
+
+ if(_.isArray(dep)) {
+ _.each(dep, function(subDep) {
+ installDependency(subDep, key);
+ });
+ } else {
+ installDependency(dep, key);
+ }
+ });
+
+ });
+
View
@@ -1,6 +1,6 @@
{
"name": "bower-installer",
- "version": "0.0.11",
+ "version": "0.1.0",
"description": "Tool for installing bower dependencies that won't include entire repos",
"main": "bower-installer",
"dependencies": {
View
@@ -0,0 +1,37 @@
+{
+ "name": "sf2",
+ "version": "2.0.0",
+ "main": "./src/main/webapp/app/index.html",
+ "dependencies": {
+ "jquery-ui" : "latest",
+ "jquery.transit" : "latest",
+ "datejs" : "latest",
+ "jquery-file-upload" : "git://github.com/blittle/jQuery-File-Upload.git",
+ "d3" : "latest",
+ "backbone" : "latest",
+ "backbone-nested" : "latest",
+ "requirejs" : "latest",
+ "underscore.string" : "latest",
+ "json2" : "latest",
+ "requirejs-text" : "latest",
+ "jquery.atmosphere" : "latest",
+ "speak.js" : "latest",
+ "buster.js" : "latest",
+ "buster-jquery-assertions" : "latest",
+ "jquery.jscrollpane" : "latest",
+ "sinon.js" : "latest",
+ "jquery-mousewheel" : "latest"
+ },
+ "install": {
+ "path": "build/src",
+ "sources": {
+ "datejs" : "components/datejs/build/date.js",
+ "jquery-file-upload" : "components/jquery-file-upload/js/jquery.fileupload.js",
+ "jquery-mousewheel" : "components/jquery-mousewheel/jquery.mousewheel.js",
+ "jquery.transit" : "components/jquery.transit/jquery.transit.js",
+ "json2" : "components/json2/json2.js",
+ "requirejs" : "components/requirejs/require.js",
+ "underscore.string" : "components/underscore.string/dist/underscore.string.min.js"
+ }
+ }
+}

0 comments on commit a2f3041

Please sign in to comment.