Detach direct app launches on Windows when not waiting
- Preserve app launch arguments while passing the target URL - Run non-waited direct launches detached with ignored stdio
This commit is contained in:
1 parent
d358a66439
commit
7fa5304e87
2 files changed
+41
-1
No files matched your search
@@ -510,6 +510,43 @@ it.effect("openBrowser uses PowerShell on win32", () =>
|
||||
}).pipe(Effect.provide(NodeFileSystem.layer)),
|
||||
);
|
||||
|
||||
it.effect("openBrowser detaches direct app launches on win32 when not waiting", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const dir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-open-browser-win32-app-" });
|
||||
yield* fs.writeFileString(`${dir}/chrome.exe`, "MZ");
|
||||
|
||||
const calls: Array<SpawnCall> = [];
|
||||
const open = yield* runOpen(
|
||||
{
|
||||
platform: "win32",
|
||||
env: {
|
||||
PATH: dir,
|
||||
PATHEXT: ".COM;.EXE;.BAT;.CMD",
|
||||
},
|
||||
},
|
||||
spawnHarness(calls),
|
||||
readOpen,
|
||||
);
|
||||
|
||||
yield* open.openBrowser("https://example.com", {
|
||||
app: {
|
||||
name: "chrome",
|
||||
arguments: ["--profile-directory=Work"],
|
||||
},
|
||||
});
|
||||
|
||||
assert.equal(calls.length, 1);
|
||||
assert.equal(calls[0]?.command.toLowerCase(), `${dir}/chrome.exe`.toLowerCase());
|
||||
assert.deepEqual(calls[0]?.args, ["--profile-directory=Work", "https://example.com"]);
|
||||
assert.equal(calls[0]?.detached, true);
|
||||
assert.equal(calls[0]?.shell, false);
|
||||
assert.equal(calls[0]?.stdin, "ignore");
|
||||
assert.equal(calls[0]?.stdout, "ignore");
|
||||
assert.equal(calls[0]?.stderr, "ignore");
|
||||
}).pipe(Effect.provide(NodeFileSystem.layer)),
|
||||
);
|
||||
|
||||
it.effect("openBrowser falls back from WSL PowerShell to xdg-open", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
|
||||
@@ -326,9 +326,12 @@ function makeDirectApplicationPlan(
|
||||
input: OpenExternalInput,
|
||||
app: OpenApplicationCandidate,
|
||||
): LaunchPlan {
|
||||
const wait = input.wait ?? false;
|
||||
return makeLaunchPlan(app.name, [...app.arguments, input.target], {
|
||||
wait: input.wait ?? false,
|
||||
wait,
|
||||
allowNonzeroExitCode: input.allowNonzeroExitCode ?? false,
|
||||
detached: !wait,
|
||||
...(wait ? {} : { stdio: "ignore" as const }),
|
||||
shell: false,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user