forked from danielsmith-eu/ita-matrix-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (27 loc) · 830 Bytes
/
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
'use strict';
var fs = require('fs');
var clone = require('clone');
var handleSearch = require('./handleSearch');
var winston = require('winston');
var args = process.argv.slice(2);
if (args.length !== 1) {
console.log("Usage: node index.js [searches.json]");
process.exit(1);
}
var config = JSON.parse(fs.readFileSync(args[0], 'utf8'));
if (config.hasOwnProperty("debug") && config.debug) { // optional
winston.level = "debug";
}
var getDates = function() {
return clone(config.dates);
};
var execSingleSearch = function () {
if (config.searches.length > 0) {
handleSearch(config.searches.shift(), getDates(), config).then(execSingleSearch, function (e) {
winston.error("Error: " + e);
});
} else {
winston.debug("Finished cleanly.");
}
};
execSingleSearch();