-
-
Save darkcolonist/1f40370db9db5e625e9c to your computer and use it in GitHub Desktop.
Revisions
-
darkcolonist revised this gist
Sep 10, 2015 . 1 changed file with 26 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ /** * include all js files in directory (node.js) * * each file included is concatenated to the file where it was included * like in php */ var fs = require("fs"); function include_dir(dir, recurse, filelist) { var fs = fs || require('fs'), files = fs.readdirSync(dir); filelist = filelist || []; recurse = recurse || false; files.forEach(function(file) { if (fs.statSync(dir + file).isDirectory()) { if(recurse){ filelist = include_dir(dir + file + '/', recurse, filelist); } } else { console.log("loading "+(dir + file)); eval(fs.readFileSync(dir + file).toString()); } }); } -
darkcolonist revised this gist
Sep 10, 2015 . 1 changed file with 11 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,21 @@ var walkSync = function(dir, recurse, filelist) { var fs = fs || require('fs'), files = fs.readdirSync(dir); filelist = filelist || []; recurse = recurse || false; files.forEach(function(file) { if (fs.statSync(dir + file).isDirectory()) { if(recurse){ filelist = walkSync(dir + file + '/', recurse, filelist); } } else { filelist.push(dir+file); } }); return filelist; }; console.log(walkSync("./", true)); -
kethinov created this gist
Sep 22, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ // List all files in a directory in Node.js recursively in a synchronous fashion var walkSync = function(dir, filelist) { var fs = fs || require('fs'), files = fs.readdirSync(dir); filelist = filelist || []; files.forEach(function(file) { if (fs.statSync(dir + file).isDirectory()) { filelist = walkSync(dir + file + '/', filelist); } else { filelist.push(file); } }); return filelist; };