Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai d68315131f fix(dev): apply the worktree's Vite URL when dev:app is given a project path
`pnpm dev:app <path>` appended `--config {devUrl}` after the path, and `tauri dev`
hands the first positional argument and everything after it to the app. The config was
dropped: tauri ran `pnpm dev` on port 1420 as well, and a full reload loaded that server
instead of the worktree's, failing with "Could not load startup script". The config now goes
before the first positional argument.
2026-11-14 01:10:07 +08:00
2 змінених файлів з 26 додано та 2 видалено

No files matched your search

+13
Переглянути файл
@@ -92,4 +92,17 @@ describe("development worktrees", () => {
expect(args.slice(-5)).toEqual(["--", "--features", "test", "--", "/project"]);
expect(JSON.parse(args[4]!)).toEqual({ build: { beforeDevCommand: "", devUrl: "http://localhost:54321/" } });
});
it("puts the Vite URL before a project path, which tauri dev hands to the app with what follows", () => {
const config = JSON.stringify({ build: { beforeDevCommand: "", devUrl: "http://localhost:54321/" } });
expect(
withDevConfig(["dev", "--config", "custom.json", "/project", "--verbose"], "http://localhost:54321/"),
).toEqual(["dev", "--config", "custom.json", "--config", config, "/project", "--verbose"]);
expect(withDevConfig(["dev", "--release"], "http://localhost:54321/")).toEqual([
"dev",
"--release",
"--config",
config,
]);
});
});
+13 -2
Переглянути файл
@@ -79,9 +79,20 @@ export async function claimSession(
throw new Error("No available development session port");
}
/** `tauri dev` options that take a value as the next argument. */
const VALUE_OPTIONS = new Set(["-c", "--config", "-t", "--target", "-f", "--features", "-r", "--runner", "--port"]);
/**
* `args` with the session's Vite URL as the last `--config`, placed before the first
* positional argument: `tauri dev` passes everything from there on to the app, so a config
* after `pnpm dev:app <project path>` would be ignored.
*/
export function withDevConfig(args: string[], devUrl: string): string[] {
const separator = args.indexOf("--");
const index = separator < 0 ? args.length : separator;
let index = 1;
while (index < args.length && args[index] !== "--" && args[index]!.startsWith("-")) {
index += VALUE_OPTIONS.has(args[index]!) ? 2 : 1;
}
index = Math.min(index, args.length);
return [
...args.slice(0, index),
"--config",