-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
61 lines (49 loc) · 1.6 KB
/
main.ts
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
55
56
57
58
59
60
61
/*
* BSD 3-Clause License
*
* Copyright © 2022, Jacob B. Sanders, IaC-Factory & Affiliates
*
* All Rights Reserved
*/
import FS from "fs";
import Awaitable from "async_hooks";
import "dotenv/config";
import Dot from "dotenv";
import Expansion from "dotenv-expand";
const { fd: output } = process.stdout;
const logger = { indent: 0 };
export const Runtime = Awaitable.createHook( {
init(asyncId: number, type: string, triggerAsyncId: number) {
const eid = Awaitable.executionAsyncId();
const indentation = " ".repeat( logger.indent );
FS.writeSync( output, `${ indentation } Before: ${ asyncId }\n` );
},
before(asyncId: number) {
const indentation = " ".repeat( logger.indent );
FS.writeSync( output, `${ indentation } Before: ${ asyncId }\n` );
logger.indent += 2;
},
after(asyncId: number) {
logger.indent -= 2;
const indentation = " ".repeat( logger.indent );
FS.writeSync( output, `${ indentation } After: ${ asyncId }\n` );
},
destroy(asyncId: number) {
const indentation = " ".repeat( logger.indent );
FS.writeSync( output, `${ indentation } Destroy: ${ asyncId }\n` );
}
} );
export const Debug = ( process.argv.includes( "--debug" ) && process.argv.includes( "--runtime" ) );
export const Register = () => {
( Debug ) && Runtime.enable();
return true;
};
export const Hydrate = () => {
Expansion.expand( Dot.config() ).parsed;
return true;
};
export const Main = async () => {
void Register() && Hydrate();
return import("@iac-factory/api-core");
};
export default Main;