Skip to content

Instantly share code, notes, and snippets.

@Ommadawn
Forked from isaacs/gist:429797
Created June 9, 2010 12:08
Show Gist options
  • Save Ommadawn/431379 to your computer and use it in GitHub Desktop.
Save Ommadawn/431379 to your computer and use it in GitHub Desktop.
function readAllHelps (cb) {
var help_text = []
, didError = false
function error (er) {
if (didError) return undefined
didError = true
cb(er)
}
fs.readdir('help', function(er, files) {
if (err) return error(er)
var len = files.length
files.forEach(function (file) {
fs.readFile('help/'+file, function(er, data) {
if (didError) return undefined
if(er) return error(er)
help_text[file] = data
if (0 === --len) cb(null, help_text)
})
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment