forked from Felx-B/vscode-web
-
Notifications
You must be signed in to change notification settings - Fork 3
/
prepare-demo.js
63 lines (51 loc) · 1.87 KB
/
prepare-demo.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
var fs = require("fs");
const fse = require("fs-extra");
const child_process = require("child_process");
const rimraf = require("rimraf");
const minify = require("minify");
if (fs.existsSync("./demo/dist")) {
fs.rmdirSync("./demo/dist", { recursive: true });
}
if (fs.existsSync("./demo/lib")) {
fs.rmdirSync("./demo/lib", { recursive: true });
}
fse.copySync("./dist", "./demo/dist");
fse.copySync("./node_modules/semver-umd", "./demo/lib/semver-umd");
fse.copySync("./node_modules/vscode-oniguruma", "./demo/lib/vscode-oniguruma");
fse.copySync("./node_modules/vscode-textmate", "./demo/lib/vscode-textmate");
if (fs.existsSync("./demo/dist/extensions/vscode-web-playground")) {
fs.rmdirSync("./demo/dist/extensions/vscode-web-playground", {
recursive: true,
});
}
child_process.execSync(
"git clone https://github.com/microsoft/vscode-web-playground.git demo/dist/extensions/vscode-web-playground",
{ stdio: "inherit" }
);
process.chdir("demo/dist/extensions/vscode-web-playground");
child_process.execSync("yarn", { stdio: "inherit" });
child_process.execSync("yarn compile", { stdio: "inherit" });
process.chdir("../../../..");
// if (fs.existsSync("./demo/dist/extensions.js")) {
// fs.unlinkSync("./demo/dist/extensions.js");
// }
const packageJSON = fs.readFileSync(
"./demo/dist/extensions/vscode-web-playground/package.json"
);
const extensions = [
{
packageJSON: JSON.parse(packageJSON),
extensionPath: "vscode-web-playground",
},
];
const content = `var playground=${JSON.stringify(extensions)}`;
fs.writeFileSync("./demo/playground.js", content);
rimraf.sync("./demo/dist/extensions/**/*.js.map");
const largeFiles = [
"./demo/dist/extensions/html-language-features/server/dist/browser/htmlServerMain.js",
];
largeFiles.map((largeFile) => {
minify(largeFile)
.then((content) => fs.writeFileSync(largeFile, content))
.catch(console.error);
});