|
1 | | -import { execSync } from "child_process" |
2 | | -import { existsSync, rmSync } from "fs" |
3 | | -import path from "path" |
| 1 | +import { execSync } from "child_process"; |
| 2 | +import { existsSync, rmSync } from "fs"; |
| 3 | +import path from "path"; |
| 4 | +import { fileURLToPath } from "url"; |
4 | 5 |
|
5 | | -const url = process.argv[2] |
6 | | -const match = /^(.+)#(.+)$/.exec(url) |
| 6 | +const __dirname = path.dirname(fileURLToPath(import.meta.url)); |
| 7 | + |
| 8 | +const url = process.argv[2]; |
| 9 | +const match = /^(.+)#(.+)$/.exec(url); |
7 | 10 | if (!match) { |
8 | | - console.error(`Please pass a git URL followed by a # and then a branch name, tag, or commit as the parameter to this script, e.g. https://github.com/processing/p5.js.git#main`) |
9 | | - process.exit(1) |
| 11 | + console.error( |
| 12 | + `Please pass a git URL followed by a # and then a branch name, tag, or commit as the parameter to this script, e.g. https://github.com/processing/p5.js.git#main`, |
| 13 | + ); |
| 14 | + process.exit(1); |
10 | 15 | } |
11 | 16 |
|
12 | | -const repoUrl = match[1] |
13 | | -const branch = match[2] |
| 17 | +const repoUrl = match[1]; |
| 18 | +const branch = match[2]; |
14 | 19 |
|
15 | | -const env = `P5_LIBRARY_PATH='/p5.min.js' P5_REPO_URL='${repoUrl}' P5_BRANCH='${branch}'` |
| 20 | +const env = `P5_LIBRARY_PATH='/p5.min.js' P5_REPO_URL='${repoUrl}' P5_BRANCH='${branch}'`; |
16 | 21 |
|
17 | 22 | // First delete the existing cloned p5 to make sure we clone fresh |
18 | | -const parsedP5Path = path.join(__dirname, './parsers/in/p5.js/') |
| 23 | +const parsedP5Path = path.join(__dirname, "./parsers/in/p5.js/"); |
19 | 24 | if (existsSync(parsedP5Path)) { |
20 | | - rmSync(parsedP5Path, { recursive: true }) |
| 25 | + rmSync(parsedP5Path, { recursive: true }); |
21 | 26 | } |
22 | 27 |
|
23 | 28 | // Build the reference using the specified environment |
24 | | -execSync(`${env} npm run build:reference`) |
| 29 | +execSync(`${env} npm run build:reference`, { stdio: "inherit" }); |
25 | 30 |
|
26 | 31 | // Run a dev server |
27 | | -execSync(`${env} npm run dev`) |
| 32 | +execSync(`${env} npm run dev`, { stdio: "inherit" }); |
0 commit comments