Skip to content

Commit a4c3c25

Browse files
committed
fix: improve resolveSassCommand docs and restore sassPath option name
Add upstream references for sass.bat template and dart_cli_pkg#67. Rename installDir back to sassPath for consistency with QUARTO_DART_SASS.
1 parent 131418b commit a4c3c25

2 files changed

Lines changed: 21 additions & 10 deletions

File tree

src/core/dart-sass.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,36 @@ export async function dartCompile(
5858
*/
5959
export interface DartCommandOptions {
6060
/**
61-
* Override the dart-sass install directory.
61+
* Override the path to the dart-sass install directory.
6262
* Used for testing with non-standard paths (spaces, accented characters).
6363
*/
64-
installDir?: string;
64+
sassPath?: string;
6565
}
6666

6767
/**
6868
* Resolve the dart-sass command and its base arguments.
6969
*
70-
* On Windows, calls dart.exe + sass.snapshot directly to avoid .bat file
71-
* issues: Deno quoting bugs (#13997), cmd.exe encoding (#14267), and
72-
* enterprise .bat blocking (#6651).
70+
* On Windows, calls dart.exe + sass.snapshot directly instead of going
71+
* through sass.bat. The bundled sass.bat is a thin wrapper generated by
72+
* dart_cli_pkg that just runs:
73+
* "%SCRIPTPATH%\src\dart.exe" "%SCRIPTPATH%\src\sass.snapshot" %arguments%
74+
*
75+
* Template source:
76+
* https://github.com/google/dart_cli_pkg/blob/main/lib/src/templates/standalone/executable.bat.mustache
77+
* Upstream issue to ship standalone .exe instead of .bat + dart.exe:
78+
* https://github.com/google/dart_cli_pkg/issues/67
79+
*
80+
* Bypassing sass.bat avoids multiple .bat file issues on Windows:
81+
* - Deno quoting bugs with spaced paths (#13997)
82+
* - cmd.exe OEM code page misreading UTF-8 accented paths (#14267)
83+
* - Enterprise group policy blocking .bat execution (#6651)
7384
*/
7485
function resolveSassCommand(options?: DartCommandOptions): {
7586
cmd: string;
7687
baseArgs: string[];
7788
} {
78-
const installDir = options?.installDir;
79-
if (installDir == null) {
89+
const sassPath = options?.sassPath;
90+
if (sassPath == null) {
8091
const dartOverrideCmd = Deno.env.get("QUARTO_DART_SASS");
8192
if (dartOverrideCmd) {
8293
if (!existsSync(dartOverrideCmd)) {
@@ -89,7 +100,7 @@ function resolveSassCommand(options?: DartCommandOptions): {
89100
}
90101
}
91102

92-
const sassDir = installDir ?? architectureToolsPath("dart-sass");
103+
const sassDir = sassPath ?? architectureToolsPath("dart-sass");
93104

94105
if (isWindows) {
95106
return {

tests/unit/dart-sass.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ unitTest(
6060
Deno.writeTextFileSync(inputScss, "body { color: red; }");
6161

6262
const result = await dartCommand([inputScss, outputCss], {
63-
installDir: spacedSassDir,
63+
sassPath: spacedSassDir,
6464
});
6565

6666
assert(
@@ -106,7 +106,7 @@ unitTest(
106106
Deno.writeTextFileSync(inputScss, "body { color: blue; }");
107107

108108
const result = await dartCommand([inputScss, outputCss], {
109-
installDir: accentedSassDir,
109+
sassPath: accentedSassDir,
110110
});
111111

112112
assert(

0 commit comments

Comments
 (0)