(from: string, to: string, replacements: Replacements)
| 7 | import { wrapInColor } from './logUtils'; |
| 8 | |
| 9 | export function copyBootstrapFiles(from: string, to: string, replacements: Replacements) { |
| 10 | copyFiles(from, to); |
| 11 | |
| 12 | const keys = Object.keys(replacements); |
| 13 | |
| 14 | const filenamesToReplace = globSync(keys.map(key => `**/{{${key}}}`)); |
| 15 | |
| 16 | for (const filename of filenamesToReplace) { |
| 17 | fs.renameSync(filename, processReplacements(filename, replacements)); |
| 18 | } |
| 19 | |
| 20 | const templateFiles = globSync(`${to}/**/*.template`); |
| 21 | templateFiles.forEach(templateFile => { |
| 22 | const parsedPath = path.parse(templateFile); |
| 23 | console.log( |
| 24 | wrapInColor(`Updating template file ${parsedPath.name} in ${parsedPath.dir}...`, ANSI_COLORS.YELLOW_COLOR), |
| 25 | ); |
| 26 | const templateFileWithoutSuffix = templateFile.replace(/.template$/, ''); |
| 27 | fs.renameSync(templateFile, templateFileWithoutSuffix); |
| 28 | copyFileWithReplacement(templateFileWithoutSuffix, templateFileWithoutSuffix, replacements); |
| 29 | }); |
| 30 | } |
no test coverage detected