UNPKG

819 BTypeScriptView Raw
1export interface RunScriptOptions {
2 /**
3 * @default false
4 * Set to true to NOT call process.exit(0) after function is completed.
5 * Currently it exists because of `jest --maxWorkers=1` behavior. To be investigated more..
6 */
7 noExit?: boolean;
8}
9/**
10 * Use it in your top-level scripts like this:
11 *
12 * runScript(async () => {
13 * await lalala()
14 * // my script goes on....
15 * })
16 *
17 * Advantages:
18 * - Works kind of like top-level await
19 * - No need to add `void`
20 * - No need to add `.then(() => process.exit()` (e.g to close DB connections)
21 * - No need to add `.catch(err => { console.error(err); process.exit(1) })`
22 *
23 * This function is kept light, dependency-free, exported separately.
24 */
25export declare function runScript(fn: (...args: any[]) => any, opt?: RunScriptOptions): void;