0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-03-17 23:11:29 -05:00

feat: create root tsconfig if doesn't exist

This commit is contained in:
Florian Lefebvre 2024-08-22 16:05:56 +02:00
parent 5ba6f2abb2
commit a73a89a311

View file

@ -167,6 +167,20 @@ export async function resolveConfig(
}
if (astroConfig.experimental.typescript) {
const rootTsConfigUrl = new URL('./tsconfig.json', astroConfig.root);
if (!fsMod.existsSync(rootTsConfigUrl)) {
fsMod.writeFileSync(
rootTsConfigUrl,
JSON.stringify(
{
extends: ['astro/tsconfigs/base', GENERATED_TSCONFIG_PATH],
},
null,
2,
),
'utf-8',
);
}
const generatedTsConfigUrl = new URL(GENERATED_TSCONFIG_PATH, astroConfig.root);
if (!fsMod.existsSync(generatedTsConfigUrl)) {
fsMod.mkdirSync(path.dirname(fileURLToPath(generatedTsConfigUrl)), { recursive: true });