Implement queue work and listen commands
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -468,4 +468,22 @@ export abstract class Directive extends AppClass {
|
||||
protected nativeOutput(...outputs: any[]): void {
|
||||
console.log(...outputs) // eslint-disable-line no-console
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a promise that resolves after SIGINT is received, executing a
|
||||
* callback beforehand.
|
||||
* @param callback
|
||||
* @protected
|
||||
*/
|
||||
protected async untilInterrupt(callback?: () => unknown): Promise<void> {
|
||||
return new Promise<void>(res => {
|
||||
process.on('SIGINT', async () => {
|
||||
if ( callback ) {
|
||||
await callback()
|
||||
}
|
||||
|
||||
res()
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user