Skip to content

Commit fa596ce

Browse files
authored
fix templater error of wrong templates path (#781)
1 parent 87049d5 commit fa596ce

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/structures/templater/ejs.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { type Data, renderFile } from "ejs";
22
import { writeFile } from "fs/promises";
3-
import { join } from "path";
43
import { type ITemplater } from "../../interfaces/templater";
4+
import { CLI_TEMPLATES_DIRNAME } from "../../utils/constants";
5+
import { joinWithRoot } from "../../utils/path";
56

67
export default class EjsTemplater implements ITemplater {
78
#readTemplateFile(inputFileName: string, props?: any) {
8-
return renderFile(join("templates", `${inputFileName}.ejs`), { props }, { async: true });
9+
return renderFile(joinWithRoot(CLI_TEMPLATES_DIRNAME, `${inputFileName}.ejs`),
10+
{ props }, { async: true });
911
}
1012

1113
#writeFile(outputFilePath: string, content: string) {

src/utils/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export const CLI_CONFIG_DIR = join(homedir(), ".discloud");
1212
export const CLI_CONFIG_FILENAME = ".cli";
1313
export const CLI_CONFIG_FILEPATH = join(CLI_CONFIG_DIR, CLI_CONFIG_FILENAME);
1414

15+
export const CLI_TEMPLATES_DIRNAME = "templates";
16+
1517
export const ERRORS_TO_IGNORE = new Set<string>([]);
1618

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

0 commit comments

Comments
 (0)