Skip to content

Instantly share code, notes, and snippets.

@kolombet
Created November 25, 2015 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kolombet/731b140122216b24160c to your computer and use it in GitHub Desktop.
Save kolombet/731b140122216b24160c to your computer and use it in GitHub Desktop.
LUKE FILEWALKER resursivly scan directory and create output
var walk = require('walk');
var files = [];
// Walker options
var walker = walk.walk('./', { followLinks: false });
var fs = require('fs');
walker.on('file', function(root, stat, next) {
files.push(stat.name);
next();
});
walker.on('end', function() {
var outputFilename = 'files.json';
fs.writeFile(outputFilename, JSON.stringify(files, null, 4), function(err) {
if(err) {
console.log(err);
} else {
console.log("JSON saved to " + outputFilename);
}
});
});
var rand = function()
{
return Math.floor(Math.random() * 1000);
}
//{
// "id": 10,
// "type": "helm",
// "sex": "male",
// "price": 100,
// "levelRequirement": 0,
// "action": "moneyMulti",
// "actionParam": 10,
// "picture": "content/equipment/-$--player-set-sets-set_02-male_helm_57.swf"
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment