(templatePath: string, outputPath?: string, replacements: Replacements = {})
| 20 | readonly basePath: string; |
| 21 | |
| 22 | private constructor(templatePath: string, outputPath?: string, replacements: Replacements = {}) { |
| 23 | this.templatePath = path.normalize(templatePath); |
| 24 | this.metaTemplatePath = path.join(Constants.META_DIR_PATH, this.templatePath); |
| 25 | |
| 26 | if (!fileExists(this.metaTemplatePath)) { |
| 27 | throw new CliError(`Template file not found: ${this.metaTemplatePath}`); |
| 28 | } |
| 29 | |
| 30 | const parsedPath = path.parse(this.templatePath); |
| 31 | this.baseName = parsedPath.name; |
| 32 | this.basePath = path.join(parsedPath.dir, parsedPath.name); |
| 33 | |
| 34 | this.outputPath = outputPath ?? path.join(process.cwd(), this.basePath); |
| 35 | this.outputPath = path.normalize(this.outputPath); |
| 36 | |
| 37 | this.replacements = replacements; |
| 38 | } |
| 39 | |
| 40 | static init(templatePath: string): TemplateFile { |
| 41 | return new TemplateFile(templatePath); |
nothing calls this directly
no test coverage detected