Skip to content

Instantly share code, notes, and snippets.

@phillipalexander
Created January 27, 2014 17:30

Revisions

  1. phillipalexander created this gist Jan 27, 2014.
    15 changes: 15 additions & 0 deletions filterFilesinCWD.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    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)