MCPcopy Create free account
hub / github.com/epicweb-dev/advanced-react-patterns / updateTsconfig

Function updateTsconfig

epicshop/fix.js:69–91  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

67}
68
69async function updateTsconfig() {
70 const tsconfig = {
71 files: [],
72 exclude: ['node_modules'],
73 references: appsWithPkgJson.map(a => ({
74 path: relativeToWorkshopRoot(a).replace(/\\/g, '/'),
75 })),
76 }
77 const written = await writeIfNeeded(
78 path.join(workshopRoot, 'tsconfig.json'),
79 `${JSON.stringify(tsconfig, null, 2)}\n`,
80 { parser: 'json' },
81 )
82
83 if (written) {
84 // delete node_modules/.cache
85 const cacheDir = path.join(workshopRoot, 'node_modules', '.cache')
86 if (exists(cacheDir)) {
87 await fs.promises.rm(cacheDir, { recursive: true })
88 }
89 console.log('all fixed up')
90 }
91}
92
93async function writeIfNeeded(filepath, content) {
94 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