fix: resolve pluginDir correctly and ensure no-reply-api is copied during install
- Use import.meta.url instead of api.resolvePath('.') to get script directory
- Add debug logging for no-reply-api and moderator bot startup
- Copy no-reply-api to dist during installation
This commit is contained in:
@@ -22,11 +22,26 @@ const __dirname = path.dirname(new URL(import.meta.url).pathname);
|
||||
// Ensure dist/dirigent exists (handles git clone without npm prepare)
|
||||
const DIST_DIR = path.resolve(__dirname, "..", "dist", "dirigent");
|
||||
const PLUGIN_SRC_DIR = path.resolve(__dirname, "..", "plugin");
|
||||
if (mode === "install" && !fs.existsSync(DIST_DIR)) {
|
||||
console.log("[dirigent] dist/ not found, syncing from plugin/...");
|
||||
fs.mkdirSync(DIST_DIR, { recursive: true });
|
||||
for (const f of fs.readdirSync(PLUGIN_SRC_DIR)) {
|
||||
fs.copyFileSync(path.join(PLUGIN_SRC_DIR, f), path.join(DIST_DIR, f));
|
||||
const NO_REPLY_API_SRC_DIR = path.resolve(__dirname, "..", "no-reply-api");
|
||||
const NO_REPLY_API_DIST_DIR = path.resolve(__dirname, "..", "dist", "no-reply-api");
|
||||
|
||||
if (mode === "install") {
|
||||
// Copy plugin files to dist/dirigent
|
||||
if (!fs.existsSync(DIST_DIR)) {
|
||||
console.log("[dirigent] dist/dirigent/ not found, syncing from plugin/...");
|
||||
fs.mkdirSync(DIST_DIR, { recursive: true });
|
||||
for (const f of fs.readdirSync(PLUGIN_SRC_DIR)) {
|
||||
fs.copyFileSync(path.join(PLUGIN_SRC_DIR, f), path.join(DIST_DIR, f));
|
||||
}
|
||||
}
|
||||
|
||||
// Copy no-reply-api files to dist/no-reply-api
|
||||
if (!fs.existsSync(NO_REPLY_API_DIST_DIR)) {
|
||||
console.log("[dirigent] dist/no-reply-api/ not found, syncing from no-reply-api/...");
|
||||
fs.mkdirSync(NO_REPLY_API_DIST_DIR, { recursive: true });
|
||||
for (const f of fs.readdirSync(NO_REPLY_API_SRC_DIR)) {
|
||||
fs.copyFileSync(path.join(NO_REPLY_API_SRC_DIR, f), path.join(NO_REPLY_API_DIST_DIR, f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user