-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
62 lines (51 loc) · 1.46 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
var path = require('path');
var async = require('async');
var config = require('histograph-config');
var parseArgs = require('minimist');
require('colors');
var steps = [
'download',
'convert',
'done'
];
var argv = parseArgs(process.argv.slice(2));
// By default, import all datasets with have data config in configuration file
var datasets = Object.keys(config.data);
if (argv._.length > 0) {
datasets = argv._;
}
async.eachSeries(datasets, function(dataset, callback) {
var importer = require('./' + path.join(dataset, dataset));
console.log('Processing dataset ' + dataset.inverse + ':');
async.eachSeries(steps, function(step, callback) {
if (!argv.steps || (argv.steps && argv.steps.split(',').indexOf(step) > -1) || step === 'done') {
if (importer[step]) {
console.log(' Executing step ' + step.underline + '...');
importer[step](config.data[dataset], function(err) {
if (err) {
console.log(' Error: '.red + JSON.stringify(err));
} else {
console.log(' Done!'.green);
}
callback(err);
});
} else {
callback();
}
} else {
if (importer[step]) {
console.log((' Skipping step ' + step.underline + '...').gray);
}
callback();
}
},
function(err) {
if (err) {
console.log('Error: '.red + err);
}
callback();
});
},
function() {
console.log('\nAll datasets done!'.green.underline);
});