MCPcopy Create free account
hub / github.com/Snapchat/Valdi / copyBootstrapFiles

Function copyBootstrapFiles

npm_modules/cli/src/utils/copyBootstrapFiles.ts:9–30  ·  view source on GitHub ↗
(from: string, to: string, replacements: Replacements)

Source from the content-addressed store, hash-verified

7import { wrapInColor } from './logUtils';
8
9export 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}

Callers 2

valdiNewModuleFunction · 0.90
initializeConfigFilesFunction · 0.90

Calls 10

copyFilesFunction · 0.90
processReplacementsFunction · 0.90
wrapInColorFunction · 0.90
copyFileWithReplacementFunction · 0.90
keysMethod · 0.65
forEachMethod · 0.65
logMethod · 0.65
replaceMethod · 0.65
mapMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected