MCPcopy Index your code
hub / github.com/codegowhere/react-inject-env / replaceFile

Function replaceFile

src/utils/File.ts:26–39  ·  view source on GitHub ↗
(dirPath: string, envConfig: Record<string, string>)

Source from the content-addressed store, hash-verified

24}
25
26export function replaceFile(dirPath: string, envConfig: Record<string, string>) {
27 const { from, to } = generateFromTo(envConfig)
28 const results = replace.sync({
29 files: `${dirPath}/**/*`,
30 from: from,
31 to: to,
32 countMatches: true
33 })
34 results.forEach((it) => {
35 if (it.hasChanged) {
36 console.info(`Replaced ${it.numReplacements} variable(s) in '${it.file}'`)
37 }
38 })
39}
40
41export function replaceFilesInDir(dir: string) {
42 const envCfg = { ...retrieveDotEnvCfg(), ...retrieveReactEnvCfg() }

Callers 1

replaceFilesInDirFunction · 0.85

Calls 1

generateFromToFunction · 0.85

Tested by

no test coverage detected