-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathimport.js
38 lines (28 loc) · 1.17 KB
/
import.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
var peliasConfig = require( 'pelias-config' ).generate(require('./schema'));
var logger = require( 'pelias-logger' ).get( 'csv-importer' );
var parameters = require( './lib/parameters' );
var importPipeline = require( './lib/importPipeline' );
// Pretty-print the total time the import took.
function startTiming() {
var startTime = new Date().getTime();
process.on( 'exit', function (){
var totalTimeTaken = (new Date().getTime() - startTime).toString();
var seconds = totalTimeTaken.slice(0, totalTimeTaken.length - 3);
var milliseconds = totalTimeTaken.slice(totalTimeTaken.length - 3);
logger.info( 'Total time taken: %s.%ss', seconds, milliseconds );
});
}
var args = parameters.interpretUserArgs( process.argv.slice( 2 ) );
if( 'exitCode' in args ){
((args.exitCode > 0) ? logger.error : logger.info)( args.errMessage );
process.exit( args.exitCode );
} else {
startTiming();
var files = parameters.getFileList(peliasConfig, args);
const importer_id = args['parallel-id'];
let importer_name = 'csv';
if (importer_id !== undefined) {
importer_name = `csv-${importer_id}`;
}
importPipeline.create( files, args.dirPath, importer_name);
}