-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
69 lines (60 loc) · 1.47 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
64
65
66
67
68
69
/**
* @license MIT
* @author aAXEe (https://github.com/aAXEe)
*/
'use strict'
const console = require('console')
const async = require('async')
const downloader = require('./metafileDownloader')
const parser = require('./metafileExtractor')
let ftpConfig = {
host: 'ftp5.gwdg.de',
remotePath: '/pub/misc/openstreetmap/openseamap/chartbundles/kap/'
}
let parserConfig = {
}
var program = require('commander')
program
.option('-d, --no-downloadTask', 'No download of meta files')
.option('-p, --no-parseTask', 'Do not parse metafiles')
.option('--downloadPath [path]', 'Path to download the data files')
.option('--metafilePath [path]', 'Path to create meta files')
.option('--outputPath [path]', 'Path for file outputs')
.parse(process.argv)
if (program.downloadPath) {
ftpConfig.downloadPath = program.downloadPath
}
if (program.metafilePath) {
ftpConfig.metafilePath = program.metafilePath
parserConfig.metafilePath = program.metafilePath
}
if (program.outputPath) {
parserConfig.outputPath = program.outputPath
}
let tasks = []
if (program.downloadTask) {
console.log('adding download task')
tasks.push((callback) => {
downloader(ftpConfig, (err) => {
callback(err)
})
})
}
if (program.parseTask) {
console.log('adding parse task')
tasks.push((callback) => {
parser(
parserConfig,
(err) => {
callback(err)
}
)
})
}
async.series(
tasks,
(err) => {
if (err) throw err
console.log('finished all tasks')
}
)