Skip to content

Commit c0b804f

Browse files
authored
Merge pull request #9061 from quarto-dev/fix/run-lua
2 parents 265e3dc + 1ad81a7 commit c0b804f

File tree

3 files changed

+62
-10
lines changed

3 files changed

+62
-10
lines changed

news/changelog-1.5.md

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ All changes included in 1.5:
121121
- ([#8937](https://github.com/quarto-dev/quarto-cli/issues/8937)): Fix unix launcher script to properly handle spaces in the path to the quarto executable.
122122
- ([#8898](https://github.com/quarto-dev/quarto-cli/issues/8898)): `.deb` and `.tar.gz` bundle contents are now associated to root user and group instead of default user and group for CI build runners.
123123
- ([#9041](https://github.com/quarto-dev/quarto-cli/issues/9041)): When creating an automatic citation key, replace spaces with underscores in inferred keys.
124+
- ([#9059](https://github.com/quarto-dev/quarto-cli/issues/9059)): `quarto run` now properly works on Windows with Lua scripts.
124125
- Add support for `{{< lipsum >}}` shortcode, which is useful for emitting placeholder text. Provide a specific number of paragraphs (`{{< lipsum 3 >}}`).
125126
- Resolve data URIs in Pandoc's mediabag when rendering documents.
126127
- Increase v8's max heap size by default, to avoid out-of-memory errors when rendering large documents (also cf. https://github.com/denoland/deno/issues/18935).

src/core/run/lua.ts

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
/*
2-
* lua.ts
3-
*
4-
* Copyright (C) 2020-2022 Posit Software, PBC
5-
*
6-
*/
2+
* lua.ts
3+
*
4+
* Copyright (C) 2020-2022 Posit Software, PBC
5+
*/
76

87
import { info } from "../../deno_ral/log.ts";
98

@@ -25,7 +24,7 @@ export const luaRunHandler: RunHandler = {
2524
options?: RunHandlerOptions,
2625
) => {
2726
// lua run handlers don't support stdin
28-
if (typeof (stdin) === "string") {
27+
if (typeof stdin === "string") {
2928
throw new Error("Lua run handlers cannot be passed stdin");
3029
}
3130

@@ -37,10 +36,6 @@ export const luaRunHandler: RunHandler = {
3736
"--to",
3837
"plain",
3938
];
40-
if (isWindows()) {
41-
cmd.push("--lua-filter");
42-
cmd.push(resourcePath("filters/init/init.lua"));
43-
}
4439
cmd.push(
4540
"--lua-filter",
4641
script,

tests/smoke/run/run-script.test.ts

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { basename, join } from "../../../src/deno_ral/path.ts";
2+
import { ensureDirSync } from "fs/mod.ts";
3+
import { assert } from "testing/asserts.ts";
4+
import { execProcess } from "../../../src/core/process.ts";
5+
import { quartoDevCmd } from "../../utils.ts";
6+
import { unitTest } from "../../test.ts";
7+
8+
const workingDir = Deno.makeTempDirSync();
9+
10+
ensureDirSync(workingDir);
11+
12+
const testRunCmd = (name: string, script: string) => {
13+
unitTest(name, async () => {
14+
const result = await execProcess({
15+
cmd: [
16+
quartoDevCmd(),
17+
"run",
18+
basename(script),
19+
],
20+
});
21+
assert(result.success);
22+
},
23+
{
24+
teardown: () => {
25+
try {
26+
Deno.removeSync(basename(script));
27+
} catch (_e) {
28+
// ignore
29+
}
30+
return Promise.resolve();
31+
},
32+
cwd: () => {
33+
return workingDir;
34+
}
35+
});
36+
}
37+
38+
// Run Lua Script
39+
const luaScript = join(workingDir, "test.lua");
40+
Deno.writeTextFileSync(luaScript, "print('Hello, world!')");
41+
testRunCmd("run-lua-script", luaScript);
42+
43+
// Run ts script
44+
const tsScript = join(workingDir, "test.ts");
45+
Deno.writeTextFileSync(tsScript, "console.log('Hello, world!')");
46+
testRunCmd("run-ts-script", tsScript);
47+
48+
// Run Python script
49+
const pyScript = join(workingDir, "test.py");
50+
Deno.writeTextFileSync(pyScript, "print('Hello, world!')");
51+
testRunCmd("run-py-script", pyScript);
52+
53+
// Run R script
54+
const rScript = join(workingDir, "test.R");
55+
Deno.writeTextFileSync(rScript, "print('Hello, world!')");
56+
testRunCmd("run-r-script", rScript);

0 commit comments

Comments
 (0)