Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions package/scripts/windows/quarto.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ IF EXIST "!QUARTO_TS_PATH!" (
GOTO end
)

call !QUARTO_ROOT!\win_configuration.bat
call "!QUARTO_ROOT!\win_configuration.bat"
REM overrride share path to point to our dev folder instead of dist
set QUARTO_SHARE_PATH=!QUARTO_ROOT!\src\resources
set "DENO_DIR=!QUARTO_BIN_PATH!\deno_cache"

IF NOT DEFINED QUARTO_ACTION (
SET QUARTO_ACTION=run
)
SET "QUARTO_IMPORT_MAP_ARG=--importmap=""!QUARTO_SRC_PATH!\import_map.json"""
SET "QUARTO_IMPORT_MAP_ARG=--importmap="!QUARTO_SRC_PATH!\import_map.json""
REM Resolve dependencies through the checked-in lockfile, as vendoring does.
REM Without it, Deno re-resolves npm packages, which needs registry metadata that
REM the vendored cache doesn't contain (and may pick versions other than the pinned ones).
SET "QUARTO_LOCK_OPTIONS=--lock=""!QUARTO_ROOT!\deno.lock"" --frozen"
SET "QUARTO_LOCK_OPTIONS=--lock="!QUARTO_ROOT!\deno.lock" --frozen"

IF NOT DEFINED QUARTO_TARGET (
SET "QUARTO_TARGET=!QUARTO_TS_PATH!"
Expand All @@ -63,7 +63,7 @@ IF EXIST "!QUARTO_TS_PATH!" (
if NOT "!DENO!"=="!DENO_INSTALLED_VERSION!" (
echo !DENO!>"!DENO_VERSION_FILE!"

cd !QUARTO_ROOT!
cd "!QUARTO_ROOT!"
call configure.cmd
echo
echo.
Expand Down Expand Up @@ -172,7 +172,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! %*
"!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! %*
)
Expand Down
95 changes: 95 additions & 0 deletions tests/unit/dev-launcher-path-with-space.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* dev-launcher-path-with-space.test.ts
*
* The dev launcher package/dist/bin/quarto.cmd must work when the checkout
* 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 {
existsSync,
readTextFileSync,
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)), "..", "..");
const denoVersionFile = join(repoRoot, "package", "dist", "config", "deno-version");

// The DENO version from the `configuration` file, which win_configuration.bat
// exports and the launcher records in config/deno-version.
function configuredDenoVersion(): string {
const configuration = readTextFileSync(join(repoRoot, "configuration"));
const match = configuration.match(/^export DENO=(\S+)/m);
assert(match, "DENO not found in configuration");
return match[1];
}

unitTest(
"dev-launcher - quarto.cmd runs from a checkout path containing a space",
async () => {
const denoVersionBefore = existsSync(denoVersionFile)
? readTextFileSync(denoVersionFile)
: undefined;
await withTempDir(async (dir) => {
const junction = join(dir, "with space");
const mklink = await execProcess({
cmd: "cmd",
args: ["/c", "mklink", "/J", junction, repoRoot],
stdout: "piped",
stderr: "piped",
});
assert(mklink.success, `creating the junction failed: ${mklink.stderr}`);
try {
const result = await execProcess({
cmd: join(junction, "package", "dist", "bin", "quarto.cmd"),
args: ["--help"],
cwd: dir,
stdout: "piped",
stderr: "piped",
env: {
QUARTO_NO_TYPECHECK: "true",
// A failed launch can reach the stale-Deno branch, which runs
// `call configure.cmd` from the checkout root. Disabling
// current-directory command lookup keeps it from reconfiguring
// the checkout under test.
NoDefaultCurrentDirectoryInExePath: "1",
},
});
const stdout = result.stdout ?? "";
const stderr = result.stderr ?? "";
const denoVersionAfter = existsSync(denoVersionFile)
? readTextFileSync(denoVersionFile)
: undefined;
// The launcher writes the file on first run, so it may not have
// existed before; either way it must hold the configured version.
assertEquals(
denoVersionAfter?.trim(),
configuredDenoVersion(),
"config/deno-version does not hold the configured Deno version",
);
assert(
result.success && stdout.includes("Usage:"),
`quarto.cmd --help failed (exit ${result.code})\nstdout:\n${stdout}\nstderr:\n${stderr}`,
);
} finally {
// Restore a deno-version the launcher may have corrupted, then remove
// the junction itself (not its target) before the temp dir goes.
if (denoVersionBefore !== undefined) {
writeTextFileSync(denoVersionFile, denoVersionBefore);
} else if (existsSync(denoVersionFile)) {
removeSync(denoVersionFile);
}
removeSync(junction);
}
});
},
{ ignore: !isWindows, requiresDevQuarto: true },
);
Loading