create-astro 3.1.1 → 3.1.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 +13 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -368,7 +368,7 @@ function printHelp({
368
368
  if (headline) {
369
369
  message.push(
370
370
  linebreak(),
371
- `${title(commandName)} ${color.green(`v${"3.1.1"}`)} ${headline}`
371
+ `${title(commandName)} ${color.green(`v${"3.1.2"}`)} ${headline}`
372
372
  );
373
373
  }
374
374
  if (usage) {
@@ -749,8 +749,13 @@ async function template(ctx) {
749
749
  start: "Template copying...",
750
750
  end: "Template copied",
751
751
  while: () => copyTemplate(ctx.template, ctx).catch((e) => {
752
- error("error", e);
753
- process.exit(1);
752
+ if (e instanceof Error) {
753
+ error("error", e.message);
754
+ process.exit(1);
755
+ } else {
756
+ error("error", "Unable to clone template.");
757
+ process.exit(1);
758
+ }
754
759
  })
755
760
  });
756
761
  } else {
@@ -788,11 +793,13 @@ async function copyTemplate(tmpl, ctx) {
788
793
  } catch (err) {
789
794
  fs3.rmdirSync(ctx.cwd);
790
795
  if (err.message.includes("404")) {
791
- await error("Error", `Template ${color5.reset(tmpl)} ${color5.dim("does not exist!")}`);
796
+ throw new Error(`Template ${color5.reset(tmpl)} ${color5.dim("does not exist!")}`);
792
797
  } else {
793
- console.error(err.message);
798
+ throw new Error(err.message);
794
799
  }
795
- ctx.exit(1);
800
+ }
801
+ if (fs3.readdirSync(ctx.cwd).length === 0) {
802
+ throw new Error(`Template ${color5.reset(tmpl)} ${color5.dim("is empty!")}`);
796
803
  }
797
804
  const removeFiles = FILES_TO_REMOVE.map(async (file) => {
798
805
  const fileLoc = path4.resolve(path4.join(ctx.cwd, file));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-astro",
3
- "version": "3.1.1",
3
+ "version": "3.1.2",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",