Any ideas on an async directory search using fs.readdir? I realise that we could introduce recursion and call the read directory function with the next directory to read, bu
check out loaddir https://npmjs.org/package/loaddir
npm install loaddir
loaddir = require('loaddir')
allJavascripts = []
loaddir({
path: __dirname + '/public/javascripts',
callback: function(){ allJavascripts.push(this.relativePath + this.baseName); }
})
You can use fileName instead of baseName if you need the extension as well.
An added bonus is that it will watch the files as well and call the callback again. There are tons of configuration options to make it extremely flexible.
I just remade the guard gem from ruby using loaddir in a short while