-
Notifications
You must be signed in to change notification settings - Fork 34
/
gatherMain.js
36 lines (33 loc) · 1021 Bytes
/
gatherMain.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
require('dotenv').config();
const fs = require('fs');
const gather = require('./gather');
const rekt = require('./gitRekt');
const args = process.argv.slice(2);
const startEnv = process.env.START_OVERRIDE || process.env.START;
const endEnv = process.env.END_OVERRIDE || process.env.END;
console.log('Starting script.');
rekt.init().then(() => {
var charList = fs.readdirSync('characters').sort();
var start = args[1] || startEnv, end = args[2] || endEnv;
switch (args[0]) {
case 'up':
start = charList.length ?
charList[charList.length - 1].
substring(0, 9) : startEnv;
end = endEnv;
break;
case 'down':
start = charList.length ? charList[0].
substring(0, 9) : endEnv;
end = startEnv;
break;
case 'range':
break;
default:
if (!args.length) break;
const t = args.map(v => Number.parseInt(v)).filter(v => !isNaN(v));
var c = 0, f = function () { if (c < t.length) gather(t[c++]).then(f); }
return f();
}
gather(Number.parseInt(start), Number.parseInt(end));
});