Skip to content

Instantly share code, notes, and snippets.

@phillipalexander
Created January 27, 2014 17:30
Show Gist options
  • Save phillipalexander/8653269 to your computer and use it in GitHub Desktop.
Save phillipalexander/8653269 to your computer and use it in GitHub Desktop.
filter files in cwd to js files
var util = require('util');
var path = require('path');
var fs = require('fs');
var allFiles = fs.readdirSync(process.cwd())
var jsFiles = [];
for (var i = 0; i < allFiles.length ; i++) {
var selectedFile = allFiles[i];
if (selectedFile.substr(selectedFile.length - 3) === '.js') {
jsFiles.push(selectedFile);
}
}
console.log(jsFiles)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment