MCPcopy Create free account
hub / github.com/Snapchat/Valdi / constructor

Method constructor

npm_modules/cli/src/utils/fileUtils.ts:22–38  ·  view source on GitHub ↗
(templatePath: string, outputPath?: string, replacements: Replacements = {})

Source from the content-addressed store, hash-verified

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);

Callers

nothing calls this directly

Calls 5

cwdMethod · 0.80
fileExistsFunction · 0.70
normalizeMethod · 0.45
joinMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected