forked from gluonjs/piscosour
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·54 lines (45 loc) · 1.12 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
'use strict';
const fs = require('fs');
const moment = require('moment');
const config = require('./lib/config');
const fsUtils = require('./lib/utils/fsUtils');
const logger = require('./lib/logger');
const relaunch = '.relaunch';
const gush = function() {
const init = moment();
const sour = require('./lib/sour');
logger.trace('Loading time', '-', '#duration', moment() - init);
sour().gush(init).then(onFulfilled, onReject);
};
const onFulfilled = function() {
if (fsUtils.exists(relaunch)) {
try {
fs.unlinkSync(relaunch);
} catch (e) {
}
process.stdout.write('\n');
config.refresh(true);
gush();
} else {
process.exit(0);
}
};
const onReject = function(e) {
let message = e;
let fatal = false;
if (e && e.stack) {
message += e.stack;
fatal = true;
console.error('\nUncatched error:\n\n', e.stack);
}
const params = require('./lib/params');
const analytics = require('./lib/analytics');
analytics.error(message, fatal, params.normal, () => {
process.exit(-1);
});
};
module.exports = {
gush: gush,
onFulfilled: onFulfilled,
onReject: onReject
};