component-builder
Advanced tools
+13
| /** | ||
| * Strip `str` quotes. | ||
| * | ||
| * @param {String} str | ||
| * @return {String} | ||
| * @api private | ||
| */ | ||
| exports.stripQuotes = function(str) { | ||
| if ('"' == str[0] || "'" == str[0]) return str.slice(1, -1); | ||
| return str; | ||
| }; |
+11
-0
| 0.5.5 / 2012-12-30 | ||
| ================== | ||
| * add lookup and readfile caching mechanisms. Closes #50 | ||
| * update require | ||
| 0.5.4 / 2012-12-20 | ||
| ================== | ||
| * remove rework dep | ||
| 0.5.3 / 2012-12-20 | ||
@@ -3,0 +14,0 @@ ================== |
+39
-13
@@ -15,3 +15,3 @@ | ||
| , mkdir = require('mkdirp') | ||
| , rework = require('rework') | ||
| , utils = require('./utils') | ||
| , dirname = path.dirname | ||
@@ -36,2 +36,3 @@ , basename = path.basename; | ||
| var self = this; | ||
| this._cache = {}; | ||
| this._hooks = {}; | ||
@@ -96,2 +97,3 @@ this._files = {}; | ||
| Builder.prototype.inherit = function(dep){ | ||
| dep._cache = this._cache; | ||
| dep._hooks = this._hooks; | ||
@@ -192,2 +194,3 @@ dep.paths = this.paths; | ||
| Builder.prototype.lookup = function(name, fn){ | ||
| var cache = this._cache; | ||
| var paths = this.paths; | ||
@@ -197,11 +200,27 @@ var self = this; | ||
| debug('lookup %s', name); | ||
| function next() { | ||
| var path = paths[i++]; | ||
| // no more paths | ||
| if (!path) return fn(new Error('failed to lookup "' + self.name + '"\'s dependency "' + name + '"')); | ||
| // path | ||
| var dir = join(path, name); | ||
| debug('check %s', dir); | ||
| var key = name + ':' + dir; | ||
| // check cache | ||
| var val = cache[key]; | ||
| if (null != val) { | ||
| if (!val) return next(); | ||
| return fn(null, val); | ||
| } | ||
| // lookup | ||
| debug('lookup %s', name); | ||
| fs.exists(dir, function(yes){ | ||
| cache[key] = false; | ||
| if (!yes) return next(); | ||
| debug('found %s', dir); | ||
| cache[key] = dir; | ||
| fn(null, dir); | ||
@@ -309,4 +328,10 @@ }); | ||
| var self = this; | ||
| var cache = this._cache; | ||
| if (this.conf) return fn(null, this.conf); | ||
| var path = this.path('component.json'); | ||
| var conf = cache[path]; | ||
| if (conf) return fn(null, this.conf = conf); | ||
| debug('reading %s', path); | ||
@@ -316,3 +341,3 @@ fs.readFile(path, 'utf8', function(err, str){ | ||
| try { | ||
| self.conf = JSON.parse(str); | ||
| self.conf = cache[path] = JSON.parse(str); | ||
| // TODO: lame, remove me | ||
@@ -777,7 +802,7 @@ if (!self._emittedConfig) { | ||
| if (builder.sourceUrls) { | ||
| return 'require.register("' + file + '", Function("module, exports, require",\n' | ||
| return 'require.register("' + file + '", Function("exports, require, module",\n' | ||
| + JSON.stringify(js + '//@ sourceURL=' + file) | ||
| + '\n));'; | ||
| } else { | ||
| return 'require.register("' + file + '", function(module, exports, require){\n' | ||
| return 'require.register("' + file + '", function(exports, require, module){\n' | ||
| + js | ||
@@ -811,12 +836,13 @@ + '\n});'; | ||
| function rewrite(url) { | ||
| if (isData(url)) return url; | ||
| if (isAbsolute(url)) return url; | ||
| function rewrite(_, url) { | ||
| var orig = 'url(' + url + ')'; | ||
| url = utils.stripQuotes(url); | ||
| if (isData(url)) return orig; | ||
| if (isAbsolute(url)) return orig; | ||
| var name = normalize(builder.name); | ||
| return join(builder.urlPrefix, '/', name, dirname(file), url); | ||
| url = join(builder.urlPrefix, '/', name, dirname(file), url); | ||
| return 'url("' + url + '")'; | ||
| } | ||
| return rework(css) | ||
| .use(rework.url(rewrite)) | ||
| .toString(); | ||
| return css.replace(/\burl *\(([^)]+)\)/g, rewrite); | ||
| } | ||
@@ -823,0 +849,0 @@ |
+2
-3
| { | ||
| "name": "component-builder", | ||
| "version": "0.5.3", | ||
| "version": "0.5.5", | ||
| "description": "Component build tool", | ||
@@ -11,5 +11,4 @@ "keywords": [ | ||
| "dependencies": { | ||
| "component-require": "0.1.0", | ||
| "component-require": "0.1.1", | ||
| "batch": "0.2.1", | ||
| "rework": "0.10.2", | ||
| "mkdirp": "0.3.4", | ||
@@ -16,0 +15,0 @@ "debug": "*", |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
23123
4.03%5
-16.67%8
14.29%755
3.85%+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated