MCPcopy Create free account
hub / github.com/chhoumann/quickadd / apply

Method apply

src/engine/TemplateInsertEngine.ts:138–156  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

136 }
137
138 public async apply(): Promise<TFile | null> {
139 invariant(
140 this.templatePath,
141 "Cannot apply template: no template path given.",
142 );
143
144 switch (this.mode) {
145 case "replace":
146 return await this.overwriteFileWithTemplate(
147 this.targetFile,
148 await this.getResolvedTemplatePath(),
149 );
150 case "top":
151 case "bottom":
152 return await this.insertTemplateIntoFile(this.mode);
153 case "cursor":
154 return await this.insertTemplateAtCursor();
155 }
156 }
157
158 /**
159 * Computes the file path the given Template choice would have produced,

Callers 4

runMethod · 0.95
applyTemplateToNoteFunction · 0.95

Calls 5

invariantFunction · 0.85

Tested by

no test coverage detected