mirror of
https://github.com/System-End/Vencord.git
synced 2026-04-19 23:22:48 +00:00
improve build watcher to also detect newly created files (#3791)
This commit is contained in:
parent
ed1060b400
commit
f87a513150
2 changed files with 13 additions and 4 deletions
|
|
@ -20,7 +20,7 @@
|
|||
// @ts-check
|
||||
|
||||
import { readdir } from "fs/promises";
|
||||
import { join } from "path";
|
||||
import { join, resolve } from "path";
|
||||
|
||||
import { BUILD_TIMESTAMP, commonOpts, exists, globPlugins, IS_DEV, IS_REPORTER, IS_ANTI_CRASH_TEST, IS_STANDALONE, IS_UPDATER_DISABLED, resolvePluginName, VERSION, commonRendererPlugins, watch, buildOrWatchAll, stringifyValues } from "./common.mjs";
|
||||
|
||||
|
|
@ -78,6 +78,10 @@ const globNativesPlugin = {
|
|||
let code = "";
|
||||
let natives = "\n";
|
||||
let i = 0;
|
||||
/**
|
||||
* @type {string[]}
|
||||
*/
|
||||
const watchFiles = [];
|
||||
for (const dir of pluginDirs) {
|
||||
const dirPath = join("src", dir);
|
||||
if (!await exists(dirPath)) continue;
|
||||
|
|
@ -87,6 +91,8 @@ const globNativesPlugin = {
|
|||
const nativePath = join(dirPath, fileName, "native.ts");
|
||||
const indexNativePath = join(dirPath, fileName, "native/index.ts");
|
||||
|
||||
watchFiles.push(resolve(nativePath), resolve(indexNativePath));
|
||||
|
||||
if (!(await exists(nativePath)) && !(await exists(indexNativePath)))
|
||||
continue;
|
||||
|
||||
|
|
@ -101,7 +107,9 @@ const globNativesPlugin = {
|
|||
code += `export default {${natives}};`;
|
||||
return {
|
||||
contents: code,
|
||||
resolveDir: "./src"
|
||||
resolveDir: "./src",
|
||||
watchDirs: pluginDirs.map(d => resolve("src", d)),
|
||||
watchFiles,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import esbuild, { build, context } from "esbuild";
|
|||
import { constants as FsConstants, readFileSync } from "fs";
|
||||
import { access, readdir, readFile } from "fs/promises";
|
||||
import { minify as minifyHtml } from "html-minifier-terser";
|
||||
import { join, relative } from "path";
|
||||
import { join, relative, resolve } from "path";
|
||||
import { promisify } from "util";
|
||||
|
||||
import { getPluginTarget } from "../utils.mjs";
|
||||
|
|
@ -190,7 +190,8 @@ export const globPlugins = kind => ({
|
|||
code += `export default {${pluginsCode}};export const PluginMeta={${metaCode}};export const ExcludedPlugins={${excludedCode}};`;
|
||||
return {
|
||||
contents: code,
|
||||
resolveDir: "./src"
|
||||
resolveDir: "./src",
|
||||
watchDirs: pluginDirs.map(d => resolve("src", d)),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue