Comparing version 0.0.3 to 0.0.4
31
index.js
@@ -13,10 +13,25 @@ var fs = require('fs'); | ||
var dirname = path.dirname(file); | ||
var pending = 0; | ||
return through(write, end); | ||
var tr = through(write, end); | ||
return tr; | ||
function write (buf) { data += buf } | ||
function end () { | ||
var tr = this; | ||
var pending = 0; | ||
try { var output = parse() } | ||
catch (err) { | ||
this.emit('error', new Error( | ||
err.toString().replace('Error: ', '') + ' (' + file + ')') | ||
); | ||
} | ||
if (pending === 0) finish(output); | ||
} | ||
function finish (output) { | ||
tr.queue(String(output)); | ||
tr.queue(null); | ||
} | ||
function parse () { | ||
var output = falafel(data, function (node) { | ||
@@ -51,13 +66,7 @@ if (isRequire(node) && node.arguments[0].value === 'fs' | ||
node.update(JSON.stringify(src)); | ||
if (--pending === 0) finish(); | ||
if (--pending === 0) finish(output); | ||
}); | ||
} | ||
}); | ||
if (pending === 0) finish(); | ||
function finish () { | ||
tr.queue(String(output)); | ||
tr.queue(null); | ||
} | ||
return output; | ||
} | ||
@@ -64,0 +73,0 @@ }; |
{ | ||
"name": "brfs", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "browserify fs.readFileSync() static asset inliner", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
10549
18
181
15