Skip to content

Instantly share code, notes, and snippets.

@JoshSalway
Created March 18, 2026 06:43
Show Gist options
  • Select an option

  • Save JoshSalway/2283ffe6cbbe450d11ccaf68990da495 to your computer and use it in GitHub Desktop.

Select an option

Save JoshSalway/2283ffe6cbbe450d11ccaf68990da495 to your computer and use it in GitHub Desktop.
Fix for laravel/vite-plugin-wayfinder #10 - Windows command execution and error reporting
From e80e60d7af641c0f20f6312ff04a6c2f66c44749 Mon Sep 17 00:00:00 2001
From: Josh Salway <josh.salway@gmail.com>
Date: Wed, 18 Mar 2026 16:42:36 +1000
Subject: [PATCH] Fix command execution on Windows and improve error reporting
On Windows, the wayfinder:generate command may fail when executed
within Vite's process context due to shell resolution or working
directory differences.
- Capture Vite's resolved root via configResolved hook and pass it
as cwd to exec, ensuring artisan is found
- Explicitly set shell: true for cross-platform compatibility
- Include stderr in error messages for easier debugging
Fixes #10
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---
src/vite-plugin-wayfinder.ts | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/vite-plugin-wayfinder.ts b/src/vite-plugin-wayfinder.ts
index 4db17db..07dfed2 100644
--- a/src/vite-plugin-wayfinder.ts
+++ b/src/vite-plugin-wayfinder.ts
@@ -52,11 +52,19 @@ export const wayfinder = ({
args.push(`--path=${path}`);
}
+ let root: string;
+
const runCommand = async () => {
try {
- await execAsync(`${command} ${args.join(" ")}`);
- } catch (error) {
- context.error("Error generating types: " + error);
+ await execAsync(`${command} ${args.join(" ")}`, {
+ cwd: root,
+ shell: true,
+ });
+ } catch (error: any) {
+ const stderr = error?.stderr ? `\n${error.stderr}` : "";
+ context.error(
+ `Error generating types: ${error?.message || error}${stderr}`,
+ );
}
context.info(`Types generated for ${generating.join(", ")}`);
@@ -65,6 +73,9 @@ export const wayfinder = ({
return {
name: "@laravel/vite-plugin-wayfinder",
enforce: "pre",
+ configResolved(config) {
+ root = config.root;
+ },
buildStart() {
context = this;
return runCommand();
--
2.53.0.windows.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment