Skip to content

Commit 87a3b19

Browse files
committed
Add --waitfor option in observable-prerender.
1 parent 95325d6 commit 87a3b19

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

bin/observable-prerender

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ let p = program
3535
"-o, --out [file]",
3636
"Output file path. Can only be used when one cell name is passed into 'cells'."
3737
)
38+
.option(
39+
"--waitfor [cells...]",
40+
"Extra cells to include in the document, but not save as a file (e.g. style cells, animation loops, etc.)."
41+
)
3842
.option(
3943
"--out-dir <directory>",
4044
"Specify a directory to save all the frames to."
@@ -50,7 +54,7 @@ p = applyRedefineOptions(p);
5054

5155
p.action(function (argNotebook, argCells) {
5256
const opts = program.opts();
53-
const { out, outDir, verbose } = opts;
57+
const { out, outDir, verbose, waitfor = [] } = opts;
5458
let { format } = opts;
5559

5660
const notebookConfig = getNotebookConfig(opts);
@@ -68,13 +72,13 @@ p.action(function (argNotebook, argCells) {
6872
}
6973

7074
format = consolidateFormat(out, format, formatOptions, "svg");
71-
75+
const cells = [...argCells, ...waitfor];
7276
if (verbose)
73-
console.log(`Loading notebook "${argNotebook}" with cells `, argCells);
77+
console.log(`Loading notebook "${argNotebook}" with cells `, cells);
7478

75-
load(argNotebook, argCells, notebookConfig).then(async (notebook) => {
79+
load(argNotebook, cells, notebookConfig).then(async (notebook) => {
7680
await runRedefines(notebook, opts, verbose);
77-
81+
await Promise.all(waitfor.map((cell) => notebook.waitFor(cell)));
7882
await Promise.all(
7983
argCells.map(async (cell) => {
8084
const path = out

0 commit comments

Comments
 (0)