diff --git a/package/scripts/windows/quarto.cmd b/package/scripts/windows/quarto.cmd index 6183f4b00aa..a426f70b9a4 100644 --- a/package/scripts/windows/quarto.cmd +++ b/package/scripts/windows/quarto.cmd @@ -109,7 +109,6 @@ IF EXIST "!QUARTO_TS_PATH!" ( SET QUARTO_ACTION=run SET "QUARTO_TARGET=%SCRIPT_PATH%\quarto.js" SET "QUARTO_BIN_PATH=%SCRIPT_PATH%" - SET "QUARTO_IMPORT_MAP_ARG=--importmap=""%SCRIPT_PATH%\vendor\import_map.json""" SET QUARTO_CACHE_OPTIONS=--cached-only ) @@ -174,7 +173,7 @@ IF DEFINED QUARTO_TS_PROFILE ( IF DEFINED QUARTO_DEV_MODE ( "!QUARTO_DENO!" !QUARTO_ACTION! !QUARTO_CACHE_OPTIONS! !QUARTO_DENO_OPTIONS! !QUARTO_DENO_EXTRA_OPTIONS! !QUARTO_IMPORT_MAP_ARG! "!QUARTO_TARGET!" %* ) ELSE ( - !QUARTO_DENO! !QUARTO_ACTION! !QUARTO_CACHE_OPTIONS! !QUARTO_DENO_OPTIONS! !QUARTO_DENO_EXTRA_OPTIONS! !QUARTO_TARGET! %* + "!QUARTO_DENO!" !QUARTO_ACTION! !QUARTO_CACHE_OPTIONS! !QUARTO_DENO_OPTIONS! !QUARTO_DENO_EXTRA_OPTIONS! "!QUARTO_TARGET!" %* ) diff --git a/tests/unit/bundled-launcher-path-with-space.test.ts b/tests/unit/bundled-launcher-path-with-space.test.ts new file mode 100644 index 00000000000..c38d3a2d886 --- /dev/null +++ b/tests/unit/bundled-launcher-path-with-space.test.ts @@ -0,0 +1,85 @@ +/* + * bundled-launcher-path-with-space.test.ts + * + * The bundled launcher bin/quarto.cmd, which the Windows installers ship next + * to quarto.exe, must work when the install path contains a space. + * + * Copyright (C) 2026 Posit Software, PBC + */ + +import { unitTest } from "../test.ts"; +import { assert, assertEquals } from "../asserts.ts"; +import { isWindows } from "../../src/deno_ral/platform.ts"; +import { dirname, fromFileUrl, join } from "../../src/deno_ral/path.ts"; +import { + copySync, + ensureDirSync, + removeSync, + writeTextFileSync, +} from "../../src/deno_ral/fs.ts"; +import { execProcess } from "../../src/core/process.ts"; +import { withTempDir } from "../utils.ts"; + +const repoRoot = join(dirname(fromFileUrl(import.meta.url)), "..", ".."); + +unitTest( + "bundled-launcher - quarto.cmd runs from an install path containing a space", + async () => { + await withTempDir(async (dir) => { + // Minimal bundled install layout: bin/quarto.cmd and bin/quarto.js, + // with no src/quarto.ts above it, so the launcher takes its bundled + // branch. bin/tools is a junction to the dev tools for deno.exe. + const bin = join(dir, "q space", "bin"); + ensureDirSync(bin); + copySync( + join(repoRoot, "package", "scripts", "windows", "quarto.cmd"), + join(bin, "quarto.cmd"), + ); + writeTextFileSync( + join(bin, "quarto.js"), + 'import process from "node:process";\n' + + 'console.log("ARGS=" + JSON.stringify(process.argv.slice(2)));\n', + ); + const tools = join(bin, "tools"); + const mklink = await execProcess({ + cmd: "cmd", + args: [ + "/c", + "mklink", + "/J", + tools, + join(repoRoot, "package", "dist", "bin", "tools"), + ], + stdout: "piped", + stderr: "piped", + }); + assert(mklink.success, `creating the junction failed: ${mklink.stderr}`); + try { + const result = await execProcess({ + cmd: join(bin, "quarto.cmd"), + args: ["check", "some arg"], + cwd: dir, + stdout: "piped", + stderr: "piped", + }); + const stdout = result.stdout ?? ""; + const stderr = result.stderr ?? ""; + const argsLine = stdout.split(/\r?\n/).find((line) => + line.startsWith("ARGS=") + ); + const details = + `(exit ${result.code})\nstdout:\n${stdout}\nstderr:\n${stderr}`; + assertEquals( + argsLine, + 'ARGS=["check","some arg"]', + `quarto.cmd did not run quarto.js with its arguments ${details}`, + ); + assert(result.success, `quarto.cmd exited with an error ${details}`); + } finally { + // Remove the junction itself (not its target) before the temp dir goes. + removeSync(tools); + } + }); + }, + { ignore: !isWindows }, +);