MCPcopy Create free account
hub / github.com/epicweb-dev/full-stack-foundations / updateTsconfig

Function updateTsconfig

epicshop/fix.js:72–94  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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