mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-11-01 16:15:24 +00:00
fix: stop dev runner restart loops and narrow plugin watchers
This commit is contained in:
1 parent
ef5057c45c
commit
ec44ba2443
1 file changed
+19
-2
+19
-2
@@ -404,6 +404,7 @@ function watchBackend() {
|
|||||||
{ cwd: root, stdio: ["ignore", "pipe", "inherit"] },
|
{ cwd: root, stdio: ["ignore", "pipe", "inherit"] },
|
||||||
);
|
);
|
||||||
let first = true;
|
let first = true;
|
||||||
|
let restartQueued = false;
|
||||||
let buffer = "";
|
let buffer = "";
|
||||||
tsc.stdout.on("data", (chunk) => {
|
tsc.stdout.on("data", (chunk) => {
|
||||||
buffer += chunk.toString();
|
buffer += chunk.toString();
|
||||||
@@ -423,14 +424,21 @@ function watchBackend() {
|
|||||||
? "starting the backend"
|
? "starting the backend"
|
||||||
: "backend changed, restarting it";
|
: "backend changed, restarting it";
|
||||||
first = false;
|
first = false;
|
||||||
void queue(() => restartBackend(reason));
|
if (restartQueued) continue;
|
||||||
|
restartQueued = true;
|
||||||
|
void queue(() => {
|
||||||
|
restartQueued = false;
|
||||||
|
return restartBackend(reason);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function watchSdk() {
|
function watchSdk() {
|
||||||
|
let buildStarted = Date.now();
|
||||||
const changed = createDebouncer(300, () =>
|
const changed = createDebouncer(300, () =>
|
||||||
queue(async () => {
|
queue(async () => {
|
||||||
|
buildStarted = Date.now();
|
||||||
try {
|
try {
|
||||||
await run("npm", ["run", "build:sdk"]);
|
await run("npm", ["run", "build:sdk"]);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -440,7 +448,16 @@ function watchSdk() {
|
|||||||
await restartBackend("SDK changed, restarting the backend");
|
await restartBackend("SDK changed, restarting the backend");
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
watch(SDK_SRC, true, () => changed("sdk"));
|
// Windows also reports reads (access time), so only a file saved after the last build counts
|
||||||
|
watch(SDK_SRC, true, (_event, filename) => {
|
||||||
|
try {
|
||||||
|
const stat = fs.statSync(path.join(SDK_SRC, String(filename ?? "")));
|
||||||
|
if (stat.isDirectory() || stat.mtimeMs < buildStarted) return;
|
||||||
|
} catch {
|
||||||
|
// deleted or renamed, still a change
|
||||||
|
}
|
||||||
|
changed("sdk");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function watchElectron() {
|
function watchElectron() {
|
||||||
|
|||||||
Reference in new issue
Block a user