-
Notifications
You must be signed in to change notification settings - Fork 105
/
build.js
93 lines (82 loc) · 2.24 KB
/
build.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
const process = require("process");
const child_process = require("child_process");
const fs = require("fs");
const fse = require("fs-extra");
const { version } = require("./package.json");
const vscodeVersion = version.split("-")[0];
function error(msg) {
console.info("\x1b[31merror %s\x1b[0m", msg);
}
function ok(msg) {
console.info("\x1b[32m%s\x1b[0m", msg);
}
function note(msg) {
console.info("\x1b[90m%s\x1b[0m", msg);
}
function exec(cmd, opts) {
console.info("\x1b[36m%s\x1b[0m", cmd);
return child_process.execSync(cmd, opts);
}
const requiredTools = ["node", "yarn", "git", "python"];
note(`required tools ${JSON.stringify(requiredTools)}`);
for (const tool of requiredTools) {
try {
child_process.execSync(`${tool} --version`, { stdio: "ignore" });
} catch (e) {
error(`"${tool}" is not available.`);
process.exit(1);
}
}
ok("required tools installed");
const node_version_out = child_process.execSync(`node -v`);
const node_version = node_version_out.toString().trim();
if (node_version < "v20.0") {
error(`Want node > 20. Got "${node_version}"`);
process.exit(1);
}
if (!fs.existsSync("vscode")) {
note("cloning vscode");
exec(
`git clone --depth 1 https://github.com/microsoft/vscode.git -b ${vscodeVersion}`,
{
stdio: "inherit",
}
);
} else {
ok("vscode already installed");
note("delete vscode folder to clone again");
}
note("changing directory to vscode");
process.chdir("vscode");
if (!fs.existsSync("node_modules")) {
exec("yarn", {
stdio: "inherit",
env: {
...process.env,
ELECTRON_SKIP_BINARY_DOWNLOAD: 1,
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1,
},
});
} else {
ok("node_modules exists. Skipping yarn");
}
// Use simple workbench
note("copying workbench file");
fs.copyFileSync(
"../workbench.ts",
"src/vs/code/browser/workbench/workbench.ts"
);
// Compile
note("starting compile");
exec("yarn gulp vscode-web-min", { stdio: "inherit" });
ok("compile completed");
// Extract compiled files
if (fs.existsSync("../dist")) {
note("cleaning ../dist");
fs.rmdirSync("../dist", { recursive: true });
} else {
ok("../dist did not exist. No need to clean");
}
fs.mkdirSync("../dist");
fse.copySync("../vscode-web", "../dist");
ok("copied ../vscode-web to ../dist");