forked from lifeomic/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlo.js
executable file
·36 lines (31 loc) · 923 Bytes
/
lo.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
#!/usr/bin/env node
'use strict';
const chalk = require('chalk');
const debug = require('debug')('lo');
try {
// Needed because the cognito library tries to fetch the user-agent from the browser
global.navigator = () => null;
require('./lib/cli').run();
} catch (err) {
debug(`%j`, err);
console.error(`\n ${err.message}`);
process.exitCode = 1;
}
process.on('uncaughtException', function (err) {
debug(`%j`, err);
console.error(err);
process.exitCode = 1;
});
process.on('unhandledRejection', function (reason, p) {
debug(`%j`, reason);
if (reason.response) {
if (reason.response.status === 401) {
console.log(`Security credentials do not exist or have expired. Use 'lo auth' to obtain new credentials.`);
} else {
console.log(chalk.red(JSON.stringify(reason.response.data, null, 2)));
}
} else {
console.error(chalk.red(reason));
}
process.exitCode = 1;
});