Provide greater abstraction for graceful shutdown#10
The current implementation relies on user providing an abort signal and triggering that signal on SIGINT. ```diff import { watch } from 'turbowatch'; +const abortController = new AbortController(); void watch({ + abortSignal: abortController.signal, project: __dirname, triggers: [ { expression: ['match', '*.ts', 'basename'], name: 'build', onChange: async ({ spawn }) => { await spawn`tsc`; }, onTeardown: async () => { await spawn`rm -fr ./dist`; }, }, ], }); +process.on('SIGINT', () => { + abortController.abort(); +}); ``` While this works for the vast majority of use cases, it introduces a fair bit of boilerplate code. It would be nice to provide an abstraction that reduces the boilerplate code. This could be as simple as: ```diff import { watch, + gracefulAbortSignal, } from 'turbowatch'; void watch({ + abortSignal: gracefulAbortSignal(), project: __dirname, triggers: [ { expression: ['match', '*.ts', 'basename'], name: 'build', onChange: async ({ spawn }) => { await spawn`tsc`; }, onTeardown: async () => { await spawn`rm -fr ./dist`; }, }, ], }); ``` We could also take a step further and just provide a fallback logic if no `abortSignal` is provided. Pros: Keeps the API simple Cons: Introduces an element of surprise if Turbowatch is used programmatically
This issue appears to be discussing a feature request or bug report related to the repository. Based on the content, it seems to be resolved. The issue was opened by gajus and has received 1 comments.