component-builder
Advanced tools
Comparing version 0.6.1 to 0.6.2
0.6.2 / 2013-01-04 | ||
================== | ||
* add .removeFile(type, filename) | ||
* add .alias() helper | ||
* rename .name to .basename | ||
* refactor .lookup() to use fs.existsSync | ||
0.6.1 / 2013-01-02 | ||
@@ -3,0 +11,0 @@ ================== |
@@ -42,3 +42,3 @@ | ||
this.parent = parent; | ||
this.name = basename(dir); | ||
this.basename = basename(dir); | ||
this.paths = ['components']; | ||
@@ -201,3 +201,3 @@ this.ignored = { | ||
// no more paths | ||
if (!path) return fn(new Error('failed to lookup "' + self.name + '"\'s dependency "' + name + '"')); | ||
if (!path) return fn(new Error('failed to lookup "' + self.basename + '"\'s dependency "' + name + '"')); | ||
@@ -217,10 +217,11 @@ // path | ||
debug('lookup %s', name); | ||
fs.exists(dir, function(yes){ | ||
cache[key] = false; | ||
if (!yes) return next(); | ||
var yes = fs.existsSync(dir); | ||
debug('found %s', dir); | ||
if (yes) { | ||
cache[key] = dir; | ||
fn(null, dir); | ||
}); | ||
return fn(null, dir); | ||
} | ||
cache[key] = false; | ||
next(); | ||
} | ||
@@ -307,2 +308,22 @@ | ||
/** | ||
* Add remove file `type` `filename` so it does not become | ||
* part of the build output, for example when transpiling | ||
* "list.styl" in the `.styles` array to "list.css", otherwise | ||
* the contents of "list.styl" will become part of the output. | ||
* | ||
* @param {String} type | ||
* @param {String} filename | ||
* @param {String} val | ||
* @return {Type} | ||
* @api public | ||
*/ | ||
Builder.prototype.removeFile = function(type, filename){ | ||
debug('remove %s "%s"', type, filename); | ||
var files = this.conf[type] || (this.conf[type] = []); | ||
var i = files.indexOf(filename); | ||
if (~i) files.splice(i, 1); | ||
}; | ||
/** | ||
* Append the given `str` of javascript. | ||
@@ -455,9 +476,7 @@ * | ||
var aliases = conf.scripts.map(function(script){ | ||
// TODO: remove special-casing root | ||
var alias = self.root | ||
? self.conf.name + '/deps/' + name + '/' + script | ||
: self.name + '/deps/' + name + '/' + script; | ||
: self.basename + '/deps/' + name + '/' + script; | ||
var js = 'require.alias("' + builder.name + '/' + script + '", "' + alias + '");\n'; | ||
return js; | ||
return builder.alias(alias, script); | ||
}); | ||
@@ -468,5 +487,5 @@ | ||
? self.conf.name + '/deps/' + name + '/index.js' | ||
: self.name + '/deps/' + name + '/index.js'; | ||
: self.basename + '/deps/' + name + '/index.js'; | ||
aliases.push('require.alias("' + builder.name + '/' + main + '", "' + alias + '");\n'); | ||
aliases.push(builder.alias(alias, main)); | ||
} | ||
@@ -491,6 +510,6 @@ | ||
? conf.name | ||
: self.name; | ||
: self.basename; | ||
if (conf.main) { | ||
res.push('require.alias("' + name + '/' + conf.main + '", "' + name + '/index.js");\n'); | ||
res.push(self.alias(name + '/index.js', conf.main)); | ||
} | ||
@@ -504,2 +523,19 @@ | ||
/** | ||
* Return an alias from script `a` to `b`. | ||
* | ||
* @param {String} a | ||
* @param {String} b | ||
* @return {String} | ||
* @api private | ||
*/ | ||
Builder.prototype.alias = function(a, b){ | ||
var name = this.root | ||
? this.conf.name | ||
: this.basename; | ||
return 'require.alias("' + name + '/' + b + '", "' + a + '");\n'; | ||
}; | ||
/** | ||
* Build `type` and invoke `fn`. | ||
@@ -515,3 +551,3 @@ * | ||
var self = this; | ||
debug('building %s %s', this.name, type); | ||
debug('building %s %s', this.basename, type); | ||
@@ -624,3 +660,3 @@ this.json(function(err, conf){ | ||
var path = self.path(file); | ||
var name = normalize(self.name); | ||
var name = normalize(self.basename); | ||
var dest = join(self.assetsDest, name, file); | ||
@@ -805,3 +841,3 @@ batch.push(function(done){ | ||
? builder.conf.name + '/' + file | ||
: builder.name + '/' + file; | ||
: builder.basename + '/' + file; | ||
@@ -847,3 +883,3 @@ if (builder.sourceUrls) { | ||
if (isAbsolute(url)) return orig; | ||
var name = normalize(builder.name); | ||
var name = normalize(builder.basename); | ||
url = join(builder.urlPrefix, '/', name, dirname(file), url); | ||
@@ -850,0 +886,0 @@ return 'url("' + url + '")'; |
{ | ||
"name": "component-builder", | ||
"version": "0.6.1", | ||
"version": "0.6.2", | ||
"description": "Component build tool", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
24338
788