Skip to content

Instantly share code, notes, and snippets.

@bittersweetryan
Created January 31, 2014 16:39

Revisions

  1. bittersweetryan created this gist Jan 31, 2014.
    22 changes: 22 additions & 0 deletions walkDirs.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    var files = [];

    function walkDirs( start ){
    //since this is happening async how can I tell when it's done to process the files
    fs.readdirSync( start, function( error, data ){

    if( error ){
    console.error( 'Oops!', error );
    }
    else{

    data.forEach( function( dirItem ){
    if( fs.lstatSync( start + '/' + dirItem ).isDirectory() ){
    return walkDirs( start + '/' + dirItem );
    }
    else{
    allFiles.push( dirItem );
    }
    });
    }
    } );
    }