Skip to content

Commit 4b2388e

Browse files
claude: Add --dev flag to quarto run command
Add a --dev flag to `quarto run` that uses the main development import map (src/import_map.json) instead of the user-facing run_import_map.json. This allows internal development tools (like import-report scripts) to access the full quarto development environment including deno_ral and other internal modules. Not visible for end users; description is for documentation purposes only. Usage: quarto run --dev script.ts [args...] The --dev flag should be used for internal quarto development tools that import from src/deno_ral or src/core. User-facing scripts should continue to use the standard `quarto run` without --dev. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5fbbf59 commit 4b2388e

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

src/command/run/run.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@ import { handlerForScript } from "../../core/run/run.ts";
1212
import { exitWithCleanup } from "../../core/cleanup.ts";
1313

1414
export async function runScript(args: string[], env?: Record<string, string>) {
15-
const script = args[0];
15+
// Check for --dev flag
16+
let dev = false;
17+
let scriptArgs = args;
18+
if (args[0] === "--dev") {
19+
dev = true;
20+
scriptArgs = args.slice(1);
21+
}
22+
23+
const script = scriptArgs[0];
1624
if (!script) {
1725
error("quarto run: no script specified");
1826
exitWithCleanup(1);
@@ -29,7 +37,10 @@ export async function runScript(args: string[], env?: Record<string, string>) {
2937
exitWithCleanup(1);
3038
throw new Error(); // unreachable
3139
}
32-
return await handler.run(script, args.slice(1), undefined, { env });
40+
return await handler.run(script, scriptArgs.slice(1), undefined, {
41+
env,
42+
dev,
43+
});
3344
}
3445

3546
// run 'command' (this is a fake command that is here just for docs,
@@ -42,4 +53,7 @@ export const runCommand = new Command()
4253
"Run a TypeScript, R, Python, or Lua script.\n\n" +
4354
"Run a utility script written in a variety of languages. For details, see:\n" +
4455
"https://quarto.org/docs/projects/scripts.html#periodic-scripts",
45-
);
56+
)
57+
.option("--dev", "Use development import map (when running from source)", {
58+
hidden: true,
59+
});

src/core/run/deno.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,17 @@ export const denoRunHandler: RunHandler = {
3434
},
3535
};
3636

37-
const importMap = normalize(join(denoDir, "../run_import_map.json"));
37+
// Choose import map based on --dev flag
38+
let importMap: string;
39+
if (options?.dev) {
40+
// Use main dev import map for internal development tools
41+
const srcDir = Deno.env.get("QUARTO_SRC_PATH") ||
42+
join(quartoConfig.sharePath(), "../../src");
43+
importMap = normalize(join(srcDir, "import_map.json"));
44+
} else {
45+
// Use user-facing run import map
46+
importMap = normalize(join(denoDir, "../run_import_map.json"));
47+
}
3848

3949
const noNet = Deno.env.get("QUARTO_RUN_NO_NETWORK") === "true";
4050

src/core/run/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface RunHandlerOptions {
1212
[key: string]: string;
1313
};
1414
stdout?: "inherit" | "piped" | "null";
15+
dev?: boolean;
1516
}
1617

1718
export interface RunHandler {

0 commit comments

Comments
 (0)