MCPcopy
hub / github.com/epicweb-dev/react-performance / updateTsconfig

Function updateTsconfig

epicshop/fix.js:87–109  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

85}
86
87async function updateTsconfig() {
88 const tsconfig = {
89 files: [],
90 exclude: ['node_modules'],
91 references: appsWithPkgJson.map((a) => ({
92 path: relativeToWorkshopRoot(a).replace(/\\/g, '/'),
93 })),
94 }
95 const written = await writeIfNeeded(
96 path.join(workshopRoot, 'tsconfig.json'),
97 `${JSON.stringify(tsconfig, null, 2)}\n`,
98 { parser: 'json' },
99 )
100
101 if (written) {
102 // delete node_modules/.cache
103 const cacheDir = path.join(workshopRoot, 'node_modules', '.cache')
104 if (exists(cacheDir)) {
105 await fs.promises.rm(cacheDir, { recursive: true })
106 }
107 console.log('all fixed up')
108 }
109}
110
111async function writeIfNeeded(filepath, content) {
112 const oldContent = await fs.promises.readFile(filepath, 'utf8')

Callers 1

fix.jsFile · 0.85

Calls 3

relativeToWorkshopRootFunction · 0.85
writeIfNeededFunction · 0.85
existsFunction · 0.85

Tested by

no test coverage detected