-
Notifications
You must be signed in to change notification settings - Fork 261
Expand file tree
/
Copy pathresetBranchTest.ts
More file actions
39 lines (32 loc) · 1.23 KB
/
resetBranchTest.ts
File metadata and controls
39 lines (32 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { fileURLToPath } from "url";
import path from "path";
import { existsSync, readFileSync, rmSync, writeFileSync } 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/en/');
const dataPath = path.join(__dirname, '../../public/reference/data.json')
rmSync(referencePath, { recursive: true });
const envFilePath = path.join(__dirname, '../../.env');
if (existsSync(envFilePath)) {
const currentEnv = readFileSync(envFilePath).toString();
writeFileSync(
envFilePath,
currentEnv
.split('\n')
.filter((line: string) => !line.startsWith('P5_') && !line.startsWith('PUBLIC_P5_') && !line.startsWith('LOCAL_P5_SOUND_PATH'))
.join('\n')
);
}
const git = simpleGit();
await git.checkout('HEAD', [referencePath, dataPath]);
const p5BuildPath = path.join(__dirname, '../../public/p5.min.js');
if (existsSync(p5BuildPath)) {
rmSync(p5BuildPath);
}
const p5WebGPUBuildPath = path.join(__dirname, '../../public/p5.webgpu.js');
if (existsSync(p5WebGPUBuildPath)) {
rmSync(p5WebGPUBuildPath);
}
}
main().then(() => process.exit(0))