Comparing version 0.6.2 to 0.6.3
@@ -12,5 +12,4 @@ | ||
, read = reader(props).read | ||
, currentFilename = null | ||
, count = 0 | ||
, ended = false | ||
, queue = [] | ||
@@ -20,2 +19,6 @@ stream.writable = true | ||
stream.pause = function () { | ||
stream.emit('pause') | ||
} | ||
stream.resume = function () { | ||
@@ -30,31 +33,20 @@ stream.emit('resume') | ||
stream.write = function (filename) { | ||
queue.push(filename) | ||
work() | ||
return true | ||
handle(filename) | ||
return false | ||
} | ||
function work () { | ||
var filename = queue[0] | ||
function handle (filename) { | ||
count++ | ||
read(filename, function (err, item) { | ||
if (err) { | ||
count-- | ||
stream.emit('error', err) | ||
stream.emit('drain') | ||
return | ||
} | ||
if (filename === currentFilename) { | ||
return | ||
} | ||
if (!filename && ended) { | ||
stream.emit('end') | ||
return | ||
} | ||
currentFilename = filename | ||
read(filename, function (err, item) { | ||
bake(item, function (err) { | ||
if (err) { | ||
stream.emit('error', err) | ||
} | ||
stream.emit('data', item.path) | ||
queue.shift() | ||
work() | ||
count-- | ||
err ? stream.emit('error', err) : stream.emit('data', item.path) | ||
stream.emit(ended && !count ? 'end' : 'drain') | ||
}) | ||
@@ -66,5 +58,4 @@ }) | ||
if (!item.bake) { | ||
return callback(new Error( | ||
'Undefined bake function for ' + item.name | ||
)) | ||
callback(new Error('Undefined bake function for ' + item.name)) | ||
return | ||
} | ||
@@ -71,0 +62,0 @@ |
@@ -17,2 +17,7 @@ // read - read files and return blake items | ||
me.read = function (path, callback) { | ||
if (!path) { | ||
callback(new Error('No Path')) | ||
return | ||
} | ||
fs.stat(path, function (err, stats) { | ||
@@ -19,0 +24,0 @@ if (stats.isDirectory()) { |
{ | ||
"name": "blake", | ||
"description": "Simple, blog aware infrastructure to generate static sites", | ||
"version": "0.6.2", | ||
"version": "0.6.3", | ||
"homepage": "http://michaelnisi.github.com/blake/", | ||
@@ -6,0 +6,0 @@ "repository": { |
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
30956
544