component-builder
Advanced tools
Comparing version 0.1.0 to 0.2.0
0.2.0 / 2012-10-22 | ||
================== | ||
* add lookup path support [Nick Jackson] | ||
0.1.0 / 2012-10-19 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -30,2 +30,3 @@ | ||
function Builder(dir, parent) { | ||
var self = this; | ||
this.dir = dir; | ||
@@ -35,2 +36,3 @@ this.root = ! parent; | ||
this.name = basename(dir); | ||
this.lookups = []; | ||
this.paths = []; | ||
@@ -43,2 +45,3 @@ this.paths.push(join(dir, 'components')); | ||
}; | ||
this.on('dependency', this.inheritLookupPaths.bind(this)); | ||
} | ||
@@ -53,2 +56,14 @@ | ||
/** | ||
* Inherit lookup paths from so that subsequent | ||
* utilize the same lookup path(s). | ||
* | ||
* @param {Builder} dep | ||
* @api private | ||
*/ | ||
Builder.prototype.inheritLookupPaths = function(dep){ | ||
dep.lookups = this.lookups; | ||
}; | ||
/** | ||
* Enable "devDependencies" in the build. | ||
@@ -73,3 +88,3 @@ * | ||
var conf = this.conf; | ||
if (conf.bundled) return true; | ||
if (conf.local) return true; | ||
if (conf.dependencies) return true; | ||
@@ -80,3 +95,3 @@ if (this.dev && conf.development) return true; | ||
/** | ||
* Return bundled dependencies object. | ||
* Return local dependencies object. | ||
* | ||
@@ -87,4 +102,4 @@ * @return {Object} | ||
Builder.prototype.bundled = function(){ | ||
return this.conf.bundled.reduce(function(obj, name){ | ||
Builder.prototype.local = function(){ | ||
return this.conf.local.reduce(function(obj, name){ | ||
obj[name] = '*'; | ||
@@ -106,3 +121,3 @@ return obj; | ||
if (this.dev) merge(deps, conf.development || {}); | ||
if (conf.bundled) merge(deps, this.bundled()); | ||
if (conf.local) merge(deps, this.local()); | ||
return deps; | ||
@@ -112,2 +127,15 @@ }; | ||
/** | ||
* Add lookup path(s). | ||
* | ||
* @param {String|Array} path | ||
* @return {Builder} | ||
* @api public | ||
*/ | ||
Builder.prototype.addLookup = function(path){ | ||
this.lookups = this.lookups.concat(path); | ||
return this; | ||
} | ||
/** | ||
* Lookup component `name` using `.paths` | ||
@@ -122,3 +150,3 @@ * and invoke `fn(err, dir)`. | ||
Builder.prototype.lookup = function(name, fn){ | ||
var paths = this.paths; | ||
var paths = [].concat(this.lookups, this.paths); | ||
var i = 0; | ||
@@ -129,3 +157,3 @@ | ||
var path = paths[i++]; | ||
if (!path) return fn(); | ||
if (!path) return fn(new Error('failed to lookup dependency "' + name + '"')); | ||
var dir = join(path, name); | ||
@@ -305,2 +333,3 @@ debug('lookup check %s', dir); | ||
var builder = new Builder(dir, self); | ||
self.emit('dependency', builder); | ||
builder.json(function(err, conf){ | ||
@@ -307,0 +336,0 @@ if (err) return done(err); |
{ | ||
"name": "component-builder", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Component build tool", | ||
@@ -5,0 +5,0 @@ "keywords": ["component", "build"], |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14311
449