( inputFilePath: string, outputFilePath: string, replacements: Replacements, )
| 155 | |
| 156 | // Returns outputFilePath |
| 157 | export function copyFileWithReplacement( |
| 158 | inputFilePath: string, |
| 159 | outputFilePath: string, |
| 160 | replacements: Replacements, |
| 161 | ): string { |
| 162 | // Read the input file content |
| 163 | const inputContent = fs.readFileSync(inputFilePath, 'utf8'); |
| 164 | |
| 165 | // Replace the keys in the input content with the corresponding values |
| 166 | const outputContent = processReplacements(inputContent, replacements); |
| 167 | |
| 168 | // Ensure the output directory exists |
| 169 | const outputDir = path.dirname(outputFilePath); |
| 170 | if (!fs.existsSync(outputDir)) { |
| 171 | fs.mkdirSync(outputDir, { recursive: true }); |
| 172 | } |
| 173 | |
| 174 | // Write the replaced content to the output file |
| 175 | fs.writeFileSync(outputFilePath, outputContent); |
| 176 | |
| 177 | return outputFilePath; |
| 178 | } |
| 179 | |
| 180 | export function deleteAll(destPath: string) { |
| 181 | if (!isDirectory(destPath)) { |
no test coverage detected