57 lines
1.8 KiB
JavaScript
57 lines
1.8 KiB
JavaScript
const { exec } = require("child_process");
|
|
const fs = require("fs");
|
|
const ncp = require("ncp").ncp;
|
|
const path = require("path");
|
|
|
|
if (!process.cwd().endsWith("vscode")) {
|
|
// This is sometimes run from root dir instead (e.g. in VS Code tasks)
|
|
process.chdir("extensions/vscode");
|
|
}
|
|
exec("npm install", (error) => {
|
|
if (error) throw error;
|
|
console.log("npm install completed");
|
|
|
|
exec("npm run typegen", (error) => {
|
|
if (error) throw error;
|
|
console.log("npm run typegen completed");
|
|
|
|
process.chdir("../../gui");
|
|
|
|
exec("npm install", (error) => {
|
|
if (error) throw error;
|
|
console.log("npm install in gui completed");
|
|
|
|
exec("npm run build", (error, stdout, stderr) => {
|
|
if (error) {
|
|
console.log("Error running npm run build in gui");
|
|
console.log("stdout: ", stdout);
|
|
console.log("stderr: ", stderr);
|
|
throw error;
|
|
}
|
|
|
|
// Then copy over the dist folder to the VSCode extension
|
|
const vscodeGuiPath = path.join("../extensions/vscode/gui");
|
|
fs.mkdirSync(vscodeGuiPath, { recursive: true });
|
|
ncp("dist", vscodeGuiPath, (error) => {
|
|
if (error) {
|
|
console.log(
|
|
"Error copying React app build to VSCode extension: ",
|
|
error
|
|
);
|
|
throw error;
|
|
}
|
|
console.log("Copied gui build to VSCode extension");
|
|
});
|
|
|
|
if (!fs.existsSync(path.join("dist", "assets", "index.js"))) {
|
|
throw new Error("gui build did not produce index.js");
|
|
}
|
|
if (!fs.existsSync(path.join("dist", "assets", "index.css"))) {
|
|
throw new Error("gui build did not produce index.css");
|
|
}
|
|
console.log("npm run build in gui completed");
|
|
});
|
|
});
|
|
});
|
|
});
|