From 5400f1af6cdca6a71de80093c9d49cdde1f34ce5 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 4 Sep 2024 17:03:09 +0200 Subject: [PATCH] fix(windows): Deno.Command - align binary resolution with linux and mac (#25429) --- tests/unit/command_test.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/unit/command_test.ts b/tests/unit/command_test.ts index dd83525473..6352e1fc7b 100644 --- a/tests/unit/command_test.ts +++ b/tests/unit/command_test.ts @@ -975,3 +975,35 @@ Deno.test( ); }, ); + +Deno.test( + { permissions: { write: true, run: true, read: true } }, + async function commandWithCwdOrPath() { + const cwd = Deno.makeTempDirSync({ prefix: "deno_command_test" }); + try { + const suffix = Deno.build.os === "windows" ? ".exe" : ""; + Deno.mkdirSync(`${cwd}/subdir`); + Deno.copyFileSync(Deno.execPath(), `${cwd}/subdir/my_binary${suffix}`); + // cwd + { + const output = await new Deno.Command(`./my_binary${suffix}`, { + cwd: `${cwd}/subdir`, + args: ["-v"], + }).output(); + assertEquals(output.success, true); + } + // path + { + const output = await new Deno.Command(`my_binary${suffix}`, { + env: { + PATH: `${cwd}/subdir`, + }, + args: ["-v"], + }).output(); + assertEquals(output.success, true); + } + } finally { + Deno.removeSync(cwd, { recursive: true }); + } + }, +);