Skip to content

Commit

Permalink
fix(create-astro): typescript prompt handling (#5958)
Browse files Browse the repository at this point in the history
* fix(create-astro): typescript prompt handling

* fallback

* fix(create-astro): additional case

Co-authored-by: Nate Moore <nate@astro.build>
  • Loading branch information
natemoo-re and natemoo-re committed Jan 24, 2023
1 parent fb6604d commit d0d7f61
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/angry-cups-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-astro': patch
---

Fix typescript prompt handling
8 changes: 4 additions & 4 deletions packages/create-astro/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ export async function main() {
args.typescript = 'strict';
}

const tsResponse =
let tsResponse =
args.typescript ||
(
await prompts(
Expand Down Expand Up @@ -342,7 +342,7 @@ export async function main() {

if (tsResponse === 'unsure') {
await typescriptByDefault();
tsResponse.typescript = 'base';
tsResponse = 'base';
}
if (args.dryRun) {
ora().info(dim(`--dry-run enabled, skipping.`));
Expand All @@ -353,7 +353,7 @@ export async function main() {
// If the template doesn't have a tsconfig.json, let's add one instead
fs.writeFileSync(
templateTSConfigPath,
stringify({ extends: `astro/tsconfigs/${tsResponse}` }, null, 2)
stringify({ extends: `astro/tsconfigs/${tsResponse ?? 'base'}` }, null, 2)
);

return;
Expand All @@ -363,7 +363,7 @@ export async function main() {

if (templateTSConfig && typeof templateTSConfig === 'object') {
const result = assign(templateTSConfig, {
extends: `astro/tsconfigs/${tsResponse.typescript}`,
extends: `astro/tsconfigs/${tsResponse ?? 'base'}`,
});

fs.writeFileSync(templateTSConfigPath, stringify(result, null, 2));
Expand Down

0 comments on commit d0d7f61

Please sign in to comment.