-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
49 lines (38 loc) · 1.1 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
const fs = require('fs');
const Notifier = require('./lib/notifier');
const cli = require('./lib/cli');
const cliHelp = require('./lib/cliHelp');
const validator = require('./lib/validator');
/**
* Load the airport file suppied by icao identifier with the `-a` flag
*
* The full file path will be built passed on the `process.cwd()` and
* and expectation that airport files live in `/assets/airports/` from
* the process root
*
* @private
* @function _loadAirportFile
* @param {CliOptionsType} options
*/
function _loadAirportFile(options) {
Notifier.start(`Loading Airport file: ${options.airport}`);
fs.readFile(options.fullPathToAirportFile, 'utf8', (err, airportJson) => {
if (err) {
Notifier.fail();
throw new Error(err);
}
Notifier.succeed();
validator(JSON.parse(airportJson), options);
});
}
(function() {
const options = cli();
if (options.shouldExit) {
cliHelp();
process.exit(0);
return;
}
Notifier.start('Parsing options');
Notifier.succeed();
_loadAirportFile(options);
})();