(files: readonly BoilerplateFile[], config: ValidatedConfig)
| 192 | * @param config the Config object, used here to get access to `sys.readFile` |
| 193 | */ |
| 194 | const checkForOverwrite = async (files: readonly BoilerplateFile[], config: ValidatedConfig): Promise<void> => { |
| 195 | const alreadyPresent: string[] = []; |
| 196 | |
| 197 | await Promise.all( |
| 198 | files.map(async ({ path }) => { |
| 199 | if ((await config.sys.readFile(path)) !== undefined) { |
| 200 | alreadyPresent.push(path); |
| 201 | } |
| 202 | }), |
| 203 | ); |
| 204 | |
| 205 | if (alreadyPresent.length > 0) { |
| 206 | config.logger.error( |
| 207 | 'Generating code would overwrite the following files:', |
| 208 | ...alreadyPresent.map((path) => '\t' + normalizePath(path)), |
| 209 | ); |
| 210 | await config.sys.exit(1); |
| 211 | } |
| 212 | }; |
| 213 | |
| 214 | /** |
| 215 | * Check if an extension is for a test |
no test coverage detected