mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-28 14:15:24 +00:00
fix: stop the dev runner rebuilding plugins when windows reports file reads as changes
This commit is contained in:
1 parent
2d71e886ac
commit
fb904554e8
8 files changed
+57
-407
No files matched your search
@@ -1,5 +1,10 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { createRequire } from "node:module";
|
||||
|
||||
const { isLocalBuildStale } = createRequire(import.meta.url)(
|
||||
"./bundled-plugins.cjs",
|
||||
);
|
||||
|
||||
const ID = /^[a-z0-9][a-z0-9-]*$/;
|
||||
const SOURCE_DIRS = new Set(["src", "locales", "migrations"]);
|
||||
@@ -19,6 +24,27 @@ export function isPluginSourceChange(filename) {
|
||||
return SOURCE_DIRS.has(parts[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a watcher event in a plugin repo is an edit worth a rebuild.
|
||||
*
|
||||
* On Windows, fs.watch also reports a folder or file being read (its last
|
||||
* access time changing, which NTFS writes lazily), so reading a repo looks
|
||||
* like editing it. Folder events are ignored, and a file event only counts
|
||||
* while its sources are newer than the last build. A path that no longer
|
||||
* exists was deleted, which always counts.
|
||||
*/
|
||||
export function isPluginEdit(repo, filename, isStale = isLocalBuildStale) {
|
||||
if (!isPluginSourceChange(filename)) return false;
|
||||
let stat;
|
||||
try {
|
||||
stat = fs.statSync(path.join(repo, String(filename)));
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
if (stat.isDirectory()) return false;
|
||||
return isStale(repo);
|
||||
}
|
||||
|
||||
/** Plugin repos under dir that can be built (manifest.json and node_modules). */
|
||||
export function findBuildablePlugins(dir) {
|
||||
const plugins = [];
|
||||
|
||||
Reference in new issue
Block a user