-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathalks.ts
More file actions
executable file
·49 lines (42 loc) · 1.42 KB
/
alks.ts
File metadata and controls
executable file
·49 lines (42 loc) · 1.42 KB
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
#!/usr/bin/env node
process.title = 'ALKS';
import clc from 'cli-color';
import { version } from '../../package.json';
import { ensureConfigFolderExists } from '../lib/configFolder';
import { convertNetrcToIni } from '../lib/convertNetrcToIni';
import { handleCommanderError } from '../lib/handlers/handleCommanderError';
import program from '../lib/program';
import { updateDbFileLocation } from '../lib/updateDbFileLocation';
import { log, initLogs } from '../lib/log';
if (process.stdout.isTTY) {
console.error(clc.whiteBright.bold('ALKS v%s'), version);
}
(async function main() {
const startTime = new Date();
let programStartTime: Date | undefined;
try {
await ensureConfigFolderExists();
await initLogs();
await convertNetrcToIni();
await updateDbFileLocation();
programStartTime = new Date();
await program.parseAsync();
} catch (err) {
logTime(startTime, programStartTime);
// We need to catch in both ways because some errors are thrown and others are rejected promises
handleCommanderError(program, err as Error);
}
logTime(startTime, programStartTime);
})();
function logTime(start: Date, programStart: Date | undefined) {
const now = new Date();
log(`time elapsed since start: ${now.getTime() - start.getTime()}`);
if (programStart) {
log(
`time elapsed while parsing program: ${
now.getTime() - programStart.getTime()
}`
);
}
}
// trivial edit.