()
| 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, |
no test coverage detected