From ed34224673ef2c5fc6436bd562da5502536b570a Mon Sep 17 00:00:00 2001 From: Gorniaky Date: Tue, 25 Nov 2025 11:39:21 -0300 Subject: [PATCH] fix templater error of wrong templates path --- src/structures/templater/ejs.ts | 6 ++++-- src/utils/constants.ts | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/structures/templater/ejs.ts b/src/structures/templater/ejs.ts index a16c21a4..e101049b 100644 --- a/src/structures/templater/ejs.ts +++ b/src/structures/templater/ejs.ts @@ -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) { diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 054181c3..96ed2cab 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -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([]); export const ERRORS_TO_LOG = new Set(["MissingRequiredOption", "Prompt", "Store", "ZodValidationError"]);