@naturalcycles/nodejs-lib
Version:
Standard library for Node.js
18 lines (17 loc) • 525 B
TypeScript
/**
* Use it in your top-level scripts like this:
*
* runScript(async () => {
* await lalala()
* // my script goes on....
* })
*
* Advantages:
* - Works kind of like top-level await
* - No need to add `void`
* - No need to add `.then(() => process.exit()` (e.g to close DB connections)
* - No need to add `.catch(err => { console.error(err); process.exit(1) })`
*
* This function is kept light, dependency-free, exported separately.
*/
export declare function runScript(fn: (...args: any[]) => any): void;