-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
executable file
·30 lines (23 loc) · 938 Bytes
/
cli.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
#!/usr/bin/env node
'use strict';
const minimist = require('minimist');
const argv = minimist(process.argv.slice(2), {
boolean: true,
});
const dateProvider = require('./lib/dateProvider.js');
const log = require('./lib/logger');
const logger = log.getLogger(log.getLevelFromArgv(argv));
process.on('unhandledRejection', (reason, p) => {
logger.error('Unhandled error: ' + reason);
});
const persister = require('./lib/persister')({argv, logger});
require('./lib/config')({argv, logger, persister}).getConfig().then((config) => {
const sub = require('./lib/sub')({argv, logger, persister, config});
const testemailcli = require('.');
logger.debug('process.argv: ' + JSON.stringify(argv));
testemailcli({ argv, config, dateProvider, logger, persister, sub }).then((result) => {
process.exit(result); // eslint no-process-exit:0
});
}, (err) => {
logger.error('failed to bootstrap config with error: ', err);
});