Skip to content

Commit c01594e

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 1ee3b56 commit c01594e

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/command/render/project.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,8 @@ export async function renderProject(
298298
await ensureGitignore(context.dir);
299299

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

306304
// if there is an output dir then remove it if clean is specified
307305
if (
@@ -332,7 +330,6 @@ export async function renderProject(
332330
...(projectRenderConfig.behavior.renderAll
333331
? { QUARTO_PROJECT_RENDER_ALL: "1" }
334332
: {}),
335-
"QUARTO_PROJECT_SCRIPT_PROGRESS": progress ? "1" : "0",
336333
};
337334

338335
// 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)