create-astro 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +11 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -253,8 +253,13 @@ ${bold(
253
253
  if (args.dryRun) {
254
254
  ora().info(dim(`--dry-run enabled, skipping.`));
255
255
  } else if (gitResponse) {
256
- await execaCommand("git init", { cwd });
257
- ora().succeed("Git repository created!");
256
+ const gitDir = "./.git";
257
+ if (fs.existsSync(gitDir)) {
258
+ ora().info(dim("A .git directory already exists. Skipping creating a new Git repository."));
259
+ } else {
260
+ await execaCommand("git init", { cwd });
261
+ ora().succeed("Git repository created!");
262
+ }
258
263
  } else {
259
264
  await info(
260
265
  "Sounds good!",
@@ -265,7 +270,7 @@ ${bold(
265
270
  ora().warn(dim('--typescript <choice> missing. Defaulting to "strict"'));
266
271
  args.typescript = "strict";
267
272
  }
268
- const tsResponse = args.typescript || (await prompts(
273
+ let tsResponse = args.typescript || (await prompts(
269
274
  {
270
275
  type: "select",
271
276
  name: "typescript",
@@ -290,7 +295,7 @@ ${bold(
290
295
  )).typescript;
291
296
  if (tsResponse === "unsure") {
292
297
  await typescriptByDefault();
293
- tsResponse.typescript = "base";
298
+ tsResponse = "base";
294
299
  }
295
300
  if (args.dryRun) {
296
301
  ora().info(dim(`--dry-run enabled, skipping.`));
@@ -300,14 +305,14 @@ ${bold(
300
305
  if (err && err.code === "ENOENT") {
301
306
  fs.writeFileSync(
302
307
  templateTSConfigPath,
303
- stringify({ extends: `astro/tsconfigs/${tsResponse}` }, null, 2)
308
+ stringify({ extends: `astro/tsconfigs/${tsResponse ?? "base"}` }, null, 2)
304
309
  );
305
310
  return;
306
311
  }
307
312
  const templateTSConfig = parse(data.toString());
308
313
  if (templateTSConfig && typeof templateTSConfig === "object") {
309
314
  const result = assign(templateTSConfig, {
310
- extends: `astro/tsconfigs/${tsResponse.typescript}`
315
+ extends: `astro/tsconfigs/${tsResponse ?? "base"}`
311
316
  });
312
317
  fs.writeFileSync(templateTSConfigPath, stringify(result, null, 2));
313
318
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-astro",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",