From 318abf470bc7108294f7b959bc2af489dec56b8d Mon Sep 17 00:00:00 2001 From: b-ma Date: Sat, 11 Jan 2025 11:52:28 +0100 Subject: [PATCH] chore: add script to preview all examples --- .scripts/run-all-examples.mjs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .scripts/run-all-examples.mjs diff --git a/.scripts/run-all-examples.mjs b/.scripts/run-all-examples.mjs new file mode 100644 index 0000000..dcfebb2 --- /dev/null +++ b/.scripts/run-all-examples.mjs @@ -0,0 +1,21 @@ +import { fork } from 'node:child_process'; +import fs from 'node:fs'; +import path from 'node:path'; +import { sleep } from '@ircam/sc-utils'; + +// run all examples for 2 seconds +const list = fs.readdirSync('examples').filter(filename => filename.endsWith('.js')); +const testDuration = 2; + +for (let i = 0; i < list.length; i++) { + const example = list[i]; + console.log(` +----------------------------------------------------------------- +- ${example} +----------------------------------------------------------------- +`); + + const proc = fork(path.join('examples', example)); + await sleep(testDuration); + proc.kill('SIGKILL'); +}