Skip to content

Instantly share code, notes, and snippets.

@LottieVixen
Created October 28, 2016 15:21
Show Gist options
  • Select an option

  • Save LottieVixen/6afee5a6d6cac7a71a5d46238c2b949b to your computer and use it in GitHub Desktop.

Select an option

Save LottieVixen/6afee5a6d6cac7a71a5d46238c2b949b to your computer and use it in GitHub Desktop.
// take directory as arg1 take exetension filter #2,
//output files that match the exetension
// must use async readdir and a callback function
var fs = require('fs');
var path = require('path');
var dir = process.argv[2];
var exe = '.'+process.argv[3];
function checkExtension(_,list){
lsArray = list;
for (var i = 0;i <= lsArray.length - 1; i++) {
if ((path.extname(lsArray[i])==exe)){
console.log(lsArray[i]);
};
};
};
fs.readdir(dir,checkExtension)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment