Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b62e380750 | |||
| 0eef560f1d | |||
| f7f42ff36c | |||
| 77d2e6ee57 | |||
| e8bd8da3c7 |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@git.zone/tswatch",
|
"name": "@git.zone/tswatch",
|
||||||
"version": "3.2.1",
|
"version": "3.2.5",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "A development tool for automatically watching and re-compiling TypeScript projects upon detecting file changes, enhancing developer workflows.",
|
"description": "A development tool for automatically watching and re-compiling TypeScript projects upon detecting file changes, enhancing developer workflows.",
|
||||||
"exports": {
|
"exports": {
|
||||||
@@ -31,11 +31,12 @@
|
|||||||
"@push.rocks/npmextra": "^5.3.3",
|
"@push.rocks/npmextra": "^5.3.3",
|
||||||
"@push.rocks/smartcli": "^4.0.20",
|
"@push.rocks/smartcli": "^4.0.20",
|
||||||
"@push.rocks/smartdelay": "^3.0.5",
|
"@push.rocks/smartdelay": "^3.0.5",
|
||||||
|
"@push.rocks/smartexit": "^2.0.2",
|
||||||
"@push.rocks/smartfs": "^1.3.1",
|
"@push.rocks/smartfs": "^1.3.1",
|
||||||
"@push.rocks/smartinteract": "^2.0.16",
|
"@push.rocks/smartinteract": "^2.0.16",
|
||||||
"@push.rocks/smartlog": "^3.1.10",
|
"@push.rocks/smartlog": "^3.1.10",
|
||||||
"@push.rocks/smartlog-destination-local": "^9.0.2",
|
"@push.rocks/smartlog-destination-local": "^9.0.2",
|
||||||
"@push.rocks/smartshell": "^3.3.2",
|
"@push.rocks/smartshell": "^3.3.5",
|
||||||
"@push.rocks/smartwatch": "^6.3.0",
|
"@push.rocks/smartwatch": "^6.3.0",
|
||||||
"@push.rocks/taskbuffer": "^4.2.0"
|
"@push.rocks/taskbuffer": "^4.2.0"
|
||||||
},
|
},
|
||||||
|
|||||||
4416
pnpm-lock.yaml
generated
4416
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -46,6 +46,14 @@ export class TsWatch {
|
|||||||
public async start() {
|
public async start() {
|
||||||
logger.log('info', 'Starting tswatch with config-driven mode');
|
logger.log('info', 'Starting tswatch with config-driven mode');
|
||||||
|
|
||||||
|
// Install global process lifecycle handlers (SIGINT, SIGTERM, etc.)
|
||||||
|
// This is the single authority for signal handling — no per-watcher handlers.
|
||||||
|
plugins.smartexit.ProcessLifecycle.install();
|
||||||
|
const exitInstance = new plugins.smartexit.SmartExit({ silent: true });
|
||||||
|
exitInstance.addCleanupFunction(async () => {
|
||||||
|
await this.stop();
|
||||||
|
});
|
||||||
|
|
||||||
// Start server if configured
|
// Start server if configured
|
||||||
if (this.config.server?.enabled) {
|
if (this.config.server?.enabled) {
|
||||||
await this.startServer();
|
await this.startServer();
|
||||||
|
|||||||
@@ -181,34 +181,13 @@ export class Watcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this method sets up a clean exit strategy
|
* Sets up timeout-based cleanup if configured.
|
||||||
|
* Signal handling (SIGINT/SIGTERM) is managed globally by ProcessLifecycle in TsWatch.
|
||||||
*/
|
*/
|
||||||
private async setupCleanup() {
|
private async setupCleanup() {
|
||||||
// Last-resort synchronous cleanup — 'exit' event cannot await async work.
|
|
||||||
// By this point, SIGINT handler should have already called stop().
|
|
||||||
process.on('exit', () => {
|
|
||||||
if (this.currentExecution && !this.currentExecution.childProcess.killed) {
|
|
||||||
const pid = this.currentExecution.childProcess.pid;
|
|
||||||
if (pid) {
|
|
||||||
try {
|
|
||||||
process.kill(pid, 'SIGKILL');
|
|
||||||
} catch {
|
|
||||||
// Process may already be dead
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
process.on('SIGINT', async () => {
|
|
||||||
console.log('');
|
|
||||||
console.log('ok! got SIGINT We are exiting! Just cleaning up to exit neatly :)');
|
|
||||||
await this.stop();
|
|
||||||
process.exit(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
// handle timeout
|
|
||||||
if (this.options.timeout) {
|
if (this.options.timeout) {
|
||||||
plugins.smartdelay.delayFor(this.options.timeout).then(async () => {
|
plugins.smartdelay.delayFor(this.options.timeout).then(async () => {
|
||||||
console.log(`timed out afer ${this.options.timeout} milliseconds! exiting!`);
|
console.log(`timed out after ${this.options.timeout} milliseconds! exiting!`);
|
||||||
await this.stop();
|
await this.stop();
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
});
|
||||||
@@ -223,7 +202,9 @@ export class Watcher {
|
|||||||
clearTimeout(this.debounceTimer);
|
clearTimeout(this.debounceTimer);
|
||||||
}
|
}
|
||||||
await this.smartwatchInstance.stop();
|
await this.smartwatchInstance.stop();
|
||||||
if (this.currentExecution && !this.currentExecution.childProcess.killed) {
|
if (this.currentExecution) {
|
||||||
|
// Always tree-kill — even if the direct child is dead (.killed === true),
|
||||||
|
// grandchildren (e.g. tsrun, devserver) may still be running.
|
||||||
await this.currentExecution.kill();
|
await this.currentExecution.kill();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import * as lik from '@push.rocks/lik';
|
|||||||
import * as npmextra from '@push.rocks/npmextra';
|
import * as npmextra from '@push.rocks/npmextra';
|
||||||
import * as smartcli from '@push.rocks/smartcli';
|
import * as smartcli from '@push.rocks/smartcli';
|
||||||
import * as smartdelay from '@push.rocks/smartdelay';
|
import * as smartdelay from '@push.rocks/smartdelay';
|
||||||
|
import * as smartexit from '@push.rocks/smartexit';
|
||||||
import * as smartfs from '@push.rocks/smartfs';
|
import * as smartfs from '@push.rocks/smartfs';
|
||||||
import * as smartinteract from '@push.rocks/smartinteract';
|
import * as smartinteract from '@push.rocks/smartinteract';
|
||||||
import * as smartlog from '@push.rocks/smartlog';
|
import * as smartlog from '@push.rocks/smartlog';
|
||||||
@@ -29,6 +30,7 @@ export {
|
|||||||
npmextra,
|
npmextra,
|
||||||
smartcli,
|
smartcli,
|
||||||
smartdelay,
|
smartdelay,
|
||||||
|
smartexit,
|
||||||
smartfs,
|
smartfs,
|
||||||
smartinteract,
|
smartinteract,
|
||||||
smartlog,
|
smartlog,
|
||||||
|
|||||||
Reference in New Issue
Block a user