feat: Allow plugins to provide Email templates
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
import path from "path";
|
||||||
|
import { glob } from "glob";
|
||||||
|
import env from "@server/env";
|
||||||
|
import Logger from "@server/logging/Logger";
|
||||||
import { requireDirectory } from "@server/utils/fs";
|
import { requireDirectory } from "@server/utils/fs";
|
||||||
|
|
||||||
const emails = {};
|
const emails = {};
|
||||||
@@ -13,4 +17,16 @@ requireDirectory(__dirname).forEach(([module, id]) => {
|
|||||||
emails[id] = Email;
|
emails[id] = Email;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const rootDir = env.ENVIRONMENT === "test" ? "" : "build";
|
||||||
|
glob
|
||||||
|
.sync(path.join(rootDir, "plugins/*/server/email/templates/!(*.test).[jt]s"))
|
||||||
|
.forEach((filePath: string) => {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
|
const template = require(path.join(process.cwd(), filePath)).default;
|
||||||
|
|
||||||
|
Logger.debug("lifecycle", `Registered email template ${template.name}`);
|
||||||
|
|
||||||
|
emails[template.name] = template;
|
||||||
|
});
|
||||||
|
|
||||||
export default emails;
|
export default emails;
|
||||||
|
|||||||
Reference in New Issue
Block a user