create-astro 5.0.3 → 5.0.5

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 +22 -11
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -289,19 +289,29 @@ import { align, sleep } from "@astrojs/cli-kit/utils";
289
289
  // src/shell.ts
290
290
  import { spawn } from "node:child_process";
291
291
  import { text as textFromStream } from "node:stream/consumers";
292
- var WINDOWS_CMD_SHIMS = /* @__PURE__ */ new Set(["npm", "npx", "pnpm", "pnpx", "yarn", "yarnpkg", "bun", "bunx"]);
292
+ var WINDOWS_CMD_SHIMS = /* @__PURE__ */ new Set(["npm", "npx", "pnpm", "pnpx", "yarn", "yarnpkg"]);
293
+ var WINDOWS_EXE_SHIMS = /* @__PURE__ */ new Set(["bun", "bunx"]);
293
294
  var text = (stream) => stream ? textFromStream(stream).then((t) => t.trimEnd()) : "";
294
- function resolveCommand(command) {
295
- if (process.platform !== "win32") return command;
296
- if (command.includes("/") || command.includes("\\") || command.includes(".")) return command;
297
- return WINDOWS_CMD_SHIMS.has(command.toLowerCase()) ? `${command}.cmd` : command;
295
+ function resolveCommand(command, flags) {
296
+ if (process.platform !== "win32") return [command, flags];
297
+ if (command.includes("/") || command.includes("\\") || command.includes("."))
298
+ return [command, flags];
299
+ const cmd = command.toLowerCase();
300
+ if (WINDOWS_CMD_SHIMS.has(cmd)) {
301
+ return ["cmd.exe", ["/d", "/s", "/c", `${command}.cmd`, ...flags]];
302
+ }
303
+ if (WINDOWS_EXE_SHIMS.has(cmd)) {
304
+ return [`${command}.exe`, flags];
305
+ }
306
+ return [command, flags];
298
307
  }
299
308
  async function shell(command, flags, opts = {}) {
300
309
  let child;
301
310
  let stdout2 = "";
302
311
  let stderr = "";
303
312
  try {
304
- child = spawn(resolveCommand(command), flags, {
313
+ const [resolvedCommand, resolvedFlags] = resolveCommand(command, flags);
314
+ child = spawn(resolvedCommand, resolvedFlags, {
305
315
  cwd: opts.cwd,
306
316
  stdio: opts.stdio,
307
317
  timeout: opts.timeout
@@ -311,15 +321,16 @@ async function shell(command, flags, opts = {}) {
311
321
  child.once("close", () => resolve());
312
322
  });
313
323
  [stdout2, stderr] = await Promise.all([text(child.stdout), text(child.stderr), done]);
314
- } catch {
315
- throw { stdout: stdout2, stderr, exitCode: 1 };
324
+ } catch (e) {
325
+ const message = e instanceof Error ? e.message : stderr || "Unknown error";
326
+ throw new Error(message);
316
327
  }
317
328
  const { exitCode } = child;
318
329
  if (exitCode === null) {
319
330
  throw new Error("Timeout");
320
331
  }
321
332
  if (exitCode !== 0) {
322
- throw new Error(stderr);
333
+ throw new Error(stderr || `Process exited with code ${exitCode}`);
323
334
  }
324
335
  return { stdout: stdout2, stderr, exitCode };
325
336
  }
@@ -459,7 +470,7 @@ function printHelp({
459
470
  if (headline) {
460
471
  message.push(
461
472
  linebreak(),
462
- `${title(commandName)} ${color.green(`v${"5.0.3"}`)} ${headline}`
473
+ `${title(commandName)} ${color.green(`v${"5.0.5"}`)} ${headline}`
463
474
  );
464
475
  }
465
476
  if (usage) {
@@ -558,7 +569,7 @@ async function getContext(argv) {
558
569
  packageManager,
559
570
  "astro",
560
571
  getPackageTag(packageSpecifier),
561
- "6.0.7"
572
+ "6.1.2"
562
573
  ),
563
574
  skipHouston,
564
575
  fancy,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-astro",
3
- "version": "5.0.3",
3
+ "version": "5.0.5",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",
@@ -30,8 +30,8 @@
30
30
  },
31
31
  "devDependencies": {
32
32
  "arg": "^5.0.2",
33
- "@astrojs/internal-helpers": "0.8.0",
34
- "astro-scripts": "0.0.14"
33
+ "astro-scripts": "0.0.14",
34
+ "@astrojs/internal-helpers": "0.8.0"
35
35
  },
36
36
  "engines": {
37
37
  "node": ">=22.12.0"