Skip to content

Instantly share code, notes, and snippets.

@marocchino
Created October 4, 2013 04:49
Show Gist options
  • Save marocchino/6821099 to your computer and use it in GitHub Desktop.
Save marocchino/6821099 to your computer and use it in GitHub Desktop.
module.exports = function (dir, ext, callback){
var fs = require('fs');
fs.readdir(dir, function(err, files){
if (err) {
callback(err);
} else {
callback(null, files.filter(function(file) {
return file.match("\\." + ext + "$");
}));
}
});
};
var listFilter = require('./listFilter.js');
listFilter(process.argv[2], process.argv[3], function(err, files){
if (err) {
console.error("error:", err);
} else {
for (var i = 0, l = files.length; i < l; i ++) {
var file = files[i];
console.log(file);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment