-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
63 lines (53 loc) · 1.65 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
SpookyJS Runner.
Looks for all .js files in root, and executes them, collecting stats on each website and reporting them via a simple UI
**/
var path = require("path"),
flow = require("flow");
var files = require("fs").readdirSync(__dirname);
flow.serialForEach(files, function(file){
//Each value in the array is passed here.
//Call 'this' as cb
if (path.extname(file) === ".js" && file != "index.js") {
try {
var operation = require(__dirname + "/" + file);
var page = new operation();
var self = this;
if (page && page.run) page.run(function(){
//Finished running.
//Grab the results object, then continue.
var stats = page.getStats();
self(); //continue on
});
}
catch (e) {
console.log("Error loading page " + e)
}
}else{
this();
}
},
function(err, newVal){
//cb results come here
//var stats =
},
function(){
//This is the end
console.log("Finished them all.");
})
//var self = this;
//
////Dynamically load .js files from the root folder.
//require("fs").readdirSync(__dirname).forEach(function (file) {
//
// if (path.extname(file) === ".js" && file != "index.js") {
// try {
// var operation = require(__dirname + "/" + file);
// var page = new operation();
// if (page && page.run) page.run(self.MULTI());
// }
// catch (e) {
// console.log("Error loading page " + e)
// }
// }
//})