-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-script-nodes.js
executable file
·43 lines (26 loc) · 1.26 KB
/
update-script-nodes.js
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
40
41
42
43
#!/usr/bin/env node
import { execSync } from "child_process";
import { cpSync, existsSync, readdirSync, readFileSync, rmSync } from "fs";
const projects = readdirSync(".");
for (const project of projects) {
if (existsSync(`${project}/phasereditor2d.config.json`)) {
console.log("Processing project", project);
if (existsSync(`${project}/package.json`)) {
console.log("Found node project");
const data = JSON.parse(readFileSync(`${project}/package.json`, "utf-8"));
for (const lib of ["@phaserjs/editor-scripts-base", "@phaserjs/editor-scripts-quick"]) {
if (data.dependencies[lib]) {
execSync(`npm install ${lib}@latest`, { cwd: project, stdio: "inherit" });
}
}
} else {
console.log("Found js project");
const PHASEREDITOR5_HOME = process.env.PHASEREDITOR5_HOME;
rmSync(`${project}/phaserjs_editor_scripts_base`, { recursive: true, force: true });
const src = `${PHASEREDITOR5_HOME}/script-nodes/editor-scripts-base/browser`;
const dst = `${project}/`;
console.log("Copying", src, "to", dst);
cpSync(src, dst, { recursive: true, force: true });
}
}
}