Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/structures/templater/ejs.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { type Data, renderFile } from "ejs";
import { writeFile } from "fs/promises";
import { join } from "path";
import { type ITemplater } from "../../interfaces/templater";
import { CLI_TEMPLATES_DIRNAME } from "../../utils/constants";
import { joinWithRoot } from "../../utils/path";

export default class EjsTemplater implements ITemplater {
#readTemplateFile(inputFileName: string, props?: any) {
return renderFile(join("templates", `${inputFileName}.ejs`), { props }, { async: true });
return renderFile(joinWithRoot(CLI_TEMPLATES_DIRNAME, `${inputFileName}.ejs`),
{ props }, { async: true });
}

#writeFile(outputFilePath: string, content: string) {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export const CLI_CONFIG_DIR = join(homedir(), ".discloud");
export const CLI_CONFIG_FILENAME = ".cli";
export const CLI_CONFIG_FILEPATH = join(CLI_CONFIG_DIR, CLI_CONFIG_FILENAME);

export const CLI_TEMPLATES_DIRNAME = "templates";

export const ERRORS_TO_IGNORE = new Set<string>([]);

export const ERRORS_TO_LOG = new Set<string>(["MissingRequiredOption", "Prompt", "Store", "ZodValidationError"]);
Expand Down
Loading