Skip to content

Commit c5a2169

Browse files
committed
Set the env var in runScript directly
which seems a better way to take into account `quiet` option in addition to progress.
1 parent accad88 commit c5a2169

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/command/render/project.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,8 @@ export async function renderProject(
296296
await ensureGitignore(context.dir);
297297

298298
// determine whether pre and post render steps should show progress
299-
const progress = (
300-
!!projectRenderConfig.options.progress ||
301-
(projectRenderConfig.filesToRender.length > 1)
302-
) && !projectRenderConfig.options.flags?.quiet;
299+
const progress = !!projectRenderConfig.options.progress ||
300+
(projectRenderConfig.filesToRender.length > 1);
303301

304302
// if there is an output dir then remove it if clean is specified
305303
if (
@@ -330,7 +328,6 @@ export async function renderProject(
330328
...(projectRenderConfig.behavior.renderAll
331329
? { QUARTO_PROJECT_RENDER_ALL: "1" }
332330
: {}),
333-
"QUARTO_PROJECT_SCRIPT_PROGRESS": progress ? "1" : "0",
334331
};
335332

336333
// run pre-render step if we are rendering all files
@@ -960,24 +957,27 @@ async function runScripts(
960957
quiet: boolean,
961958
env?: { [key: string]: string },
962959
) {
960+
// initialize the environment if needed
961+
if (env) {
962+
env = {
963+
...env,
964+
};
965+
} else {
966+
env = {};
967+
}
968+
if (!env) throw new Error("should never get here");
969+
963970
for (let i = 0; i < scripts.length; i++) {
964971
const args = parseShellRunCommand(scripts[i]);
965972
const script = args[0];
966973

967-
if (progress) {
974+
if (progress && !quiet) {
968975
info(colors.bold(colors.blue(`Running script '${script}'`)));
976+
env["QUARTO_PROJECT_SCRIPT_PROGRESS"] = "1";
969977
}
970978

971979
const handler = handlerForScript(script);
972980
if (handler) {
973-
if (env) {
974-
env = {
975-
...env,
976-
};
977-
} else {
978-
env = {};
979-
}
980-
if (!env) throw new Error("should never get here");
981981
const input = Deno.env.get("QUARTO_USE_FILE_FOR_PROJECT_INPUT_FILES");
982982
const output = Deno.env.get("QUARTO_USE_FILE_FOR_PROJECT_OUTPUT_FILES");
983983
if (input) {

0 commit comments

Comments
 (0)