Last active
August 29, 2015 14:02
-
-
Save peol/b66ad0e9976548f12298 to your computer and use it in GitHub Desktop.
Autogenerate folders/files
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 characters
var Gaze = require("gaze").Gaze; | |
var gaze = new Gaze("test_struct/**/*.js"); | |
gaze.on("ready", function(watcher) { | |
this.watched(function(e, f) { | |
var files = []; | |
Object.keys(f).forEach(function(k) { | |
f[k].forEach(function(file) { | |
files.push(file); | |
}); | |
}); | |
console.log("Watching %d files", files.length); | |
}); | |
}); | |
gaze.on("error", function(error) { | |
console.log(error); | |
}); | |
gaze.on("all", function(event, filepath) { | |
console.log(event, filepath); | |
}); |
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 characters
// node populate.js | |
// will create a test_struct/<autogen>/<autogen>.js for approx 3000 folders/files | |
var fs = require("fs"); | |
var current = 0; | |
var MAX_TOTAL = 3000; | |
function createFilesAndFolders(basePath) { | |
for (var i = 0; i < 3; i++) { | |
var folder = basePath + "\\" + i + "_Long_Folder_Name"; | |
if (folder.length > 200 || current > MAX_TOTAL) { | |
break; | |
} | |
fs.mkdirSync(folder); | |
current++; | |
for (var j = 0; j < 10; j++) { | |
var filename = folder + "\\" + j + "_Filename.js"; | |
if (filename.length > 200 || current > MAX_TOTAL) { | |
break; | |
} | |
fs.writeFileSync(filename); | |
current++; | |
} | |
createFilesAndFolders(folder); | |
} | |
} | |
var startPath = __dirname + "\\test_struct"; | |
fs.mkdirSync(startPath); | |
createFilesAndFolders(startPath); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment