UNPKG

entry-script

Version:
52 lines 1.98 kB
export interface Main { /** * Method called at the "start" of execution, if default export is an instance. * * Must be extended with any custom logic if exporting an instance. * * @param argv - parameters to script, _after_ the node executable and file name. * `node ./foo-bar.js --bing bong` -> `['--bing', 'bong']` */ main: (argv: string[]) => Promise<void>; } /** * Base class for all entry script executable files. * Extend this class and export the result as "default" * to run automatically, when that file is NodeJS' entry point. */ export declare abstract class EntryScript implements Main { /** * Method called at the "start" of execution, if default export is an instance. * * Must be extended with any custom logic if exporting an instance. * * @param argv - parameters to script, _after_ the node executable and file name. * `node ./foo-bar.js --bing bong` -> `['--bing', 'bong']` * Based off process.argv * @throws {MainNotImplementedError} when not implemented */ main(argv: string[]): Promise<void>; /** * Method called at the "start" of execution, if default export is the class. * * Must be extended with any custom logic if exporting the class. * * @param argv - parameters to script, _after_ the node executable and file name. * `node ./foo-bar.js --bing bong` -> `['--bing', 'bong']` * Based off process.argv * @throws {MainNotImplementedError} when not implemented */ static main(argv: string[]): Promise<void>; } /** * Method to load entry point module, and execute it if * it is a child class of EntryScript. * * The check happens locally (see call below) but is exported for testing purposes. * Should not be called elsewhere. * * @private * @param url - NodeJS process entry point. */ export declare const runAsMain: (url?: string) => Promise<void>; //# sourceMappingURL=entry-script.d.ts.map