-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f89448b
commit 4ea66f5
Showing
5 changed files
with
52 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
import { execSync } from "child_process" | ||
import { existsSync, rmSync } from "fs" | ||
import path from "path" | ||
import { execSync } from "child_process"; | ||
import { existsSync, rmSync } from "fs"; | ||
import path from "path"; | ||
import { fileURLToPath } from "url"; | ||
|
||
const url = process.argv[2] | ||
const match = /^(.+)#(.+)$/.exec(url) | ||
const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
|
||
const url = process.argv[2]; | ||
const match = /^(.+)#(.+)$/.exec(url); | ||
if (!match) { | ||
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`) | ||
process.exit(1) | ||
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`, | ||
); | ||
process.exit(1); | ||
} | ||
|
||
const repoUrl = match[1] | ||
const branch = match[2] | ||
const repoUrl = match[1]; | ||
const branch = match[2]; | ||
|
||
const env = `P5_LIBRARY_PATH='/p5.min.js' P5_REPO_URL='${repoUrl}' P5_BRANCH='${branch}'` | ||
const env = `P5_LIBRARY_PATH='/p5.min.js' P5_REPO_URL='${repoUrl}' P5_BRANCH='${branch}'`; | ||
|
||
// First delete the existing cloned p5 to make sure we clone fresh | ||
const parsedP5Path = path.join(__dirname, './parsers/in/p5.js/') | ||
const parsedP5Path = path.join(__dirname, "./parsers/in/p5.js/"); | ||
if (existsSync(parsedP5Path)) { | ||
rmSync(parsedP5Path, { recursive: true }) | ||
rmSync(parsedP5Path, { recursive: true }); | ||
} | ||
|
||
// Build the reference using the specified environment | ||
execSync(`${env} npm run build:reference`) | ||
execSync(`${env} npm run build:reference`, { stdio: "inherit" }); | ||
|
||
// Run a dev server | ||
execSync(`${env} npm run dev`) | ||
execSync(`${env} npm run dev`, { stdio: "inherit" }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { fileURLToPath } from "url"; | ||
import path from "path"; | ||
import { existsSync, rmSync } from "fs"; | ||
import simpleGit from "simple-git"; | ||
|
||
async function main() { | ||
const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
|
||
const referencePath = path.join(__dirname, '../content/reference/'); | ||
const dataPath = path.join(__dirname, '../../public/reference/data.json') | ||
rmSync(referencePath, { recursive: true }); | ||
|
||
const git = simpleGit(); | ||
await git.checkout('HEAD', [referencePath, dataPath]); | ||
|
||
const p5BuildPath = path.join(__dirname, '../../public/p5.min.js'); | ||
if (existsSync(p5BuildPath)) { | ||
rmSync(p5BuildPath); | ||
} | ||
} | ||
|
||
main().then(() => process.exit(0)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters