Fix issues with linux build
also add error logging to compile and install steps
This commit is contained in:
parent
dcbfa98cd9
commit
f5b594027d
18
compile.js
18
compile.js
|
@ -14,17 +14,29 @@ spawnSync("npm run build", join(__dirname, "LightcordApi"))
|
|||
spawnSync("npm run build-prod", join(__dirname, "LightcordApi"))
|
||||
spawnSync("tsc", join(__dirname, "LightcordApi"))
|
||||
|
||||
var exitedWithErrorProcessList = [];
|
||||
|
||||
function spawnSync(args, cwd){
|
||||
args = args.split(" ")
|
||||
function spawnSync(cmdString, cwd){
|
||||
let args = cmdString.split(" ")
|
||||
let command = args.shift()
|
||||
return spawn(command, args, {
|
||||
cwd: cwd || process.cwd(),
|
||||
env: process.env,
|
||||
stdio: "inherit"
|
||||
})
|
||||
}).on("error", (err) => {
|
||||
const DIRSTRING = cwd != undefined ? cwd : process.env.PWD
|
||||
console.log("Error while running " + cmdString + " in target directory " + DIRSTRING)
|
||||
console.error(err)
|
||||
exitedWithErrorProcessList.push({cmd: cmdString, cwd: DIRSTRING})
|
||||
})
|
||||
}
|
||||
|
||||
process.on("beforeExit", () => {
|
||||
if (exitedWithErrorProcessList.length != 0){
|
||||
console.error("Commands exited with errors:\n")
|
||||
exitedWithErrorProcessList.forEach((val)=>{
|
||||
console.error("\tcommand:\t\t" + val.cmd + "\n\ttarget directory:\t" + val.cwd + "\n")
|
||||
});
|
||||
}
|
||||
console.log(`Exiting compilation`)
|
||||
})
|
|
@ -4,6 +4,20 @@ const path = require("path")
|
|||
|
||||
const MODULES_DIRNAME = path.join(__dirname, "modules")
|
||||
|
||||
var exitedWithErrorProcessList = [];
|
||||
|
||||
function spawnNpmInstallProcess (targetDir) {
|
||||
child_process.spawn((process.platform === "win32" ? "npm.cmd" : "npm"), ["i"], {
|
||||
cwd: targetDir,
|
||||
env: process.env,
|
||||
stdio: "inherit"
|
||||
}).on("error", (err) => {
|
||||
console.log("Error while running 'npm i' in target directory " + targetDir)
|
||||
console.error(err)
|
||||
exitedWithErrorProcessList.push(targetDir)
|
||||
})
|
||||
}
|
||||
|
||||
fs.readdirSync(MODULES_DIRNAME, {withFileTypes: true})
|
||||
.forEach(e => {
|
||||
if(!e.isDirectory())return
|
||||
|
@ -12,43 +26,26 @@ fs.readdirSync(MODULES_DIRNAME, {withFileTypes: true})
|
|||
if(e.name === "discord_spellcheck")return
|
||||
|
||||
console.log(`Installing modules in ${e.name}.`)
|
||||
|
||||
child_process.spawn((process.platform === "win32" ? "npm.cmd" : "npm"), ["i"], {
|
||||
cwd: MODULE_DIRNAME,
|
||||
env: process.env,
|
||||
stdio: "inherit"
|
||||
}).on("error", (err) => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
spawnNpmInstallProcess(MODULE_DIRNAME)
|
||||
})
|
||||
|
||||
|
||||
const MODULE_DIRNAME = path.join(__dirname, "modules", "discord_desktop_core", "core")
|
||||
const BETTERDISCORD_DIRNAME = path.join(__dirname, "BetterDiscordApp")
|
||||
const DISCORDJS_DIRNAME = path.join(__dirname, "DiscordJS")
|
||||
const LIGHTCORDAPI_DIRNAME = path.join(__dirname, "LightcordApi")
|
||||
|
||||
child_process.spawn((process.platform === "win32" ? "npm.cmd" : "npm"), ["i"], {
|
||||
cwd: MODULE_DIRNAME,
|
||||
env: process.env,
|
||||
stdio: "inherit"
|
||||
}).on("error", (err) => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
spawnNpmInstallProcess(MODULE_DIRNAME)
|
||||
spawnNpmInstallProcess(BETTERDISCORD_DIRNAME)
|
||||
spawnNpmInstallProcess(LIGHTCORDAPI_DIRNAME)
|
||||
spawnNpmInstallProcess(DISCORDJS_DIRNAME)
|
||||
|
||||
child_process.spawn((process.platform === "win32" ? "npm.cmd" : "npm"), ["i"], {
|
||||
cwd: BETTERDISCORD_DIRNAME,
|
||||
env: process.env,
|
||||
stdio: "inherit"
|
||||
}).on("error", (err) => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
|
||||
child_process.spawn((process.platform === "win32" ? "npm.cmd" : "npm"), ["i"], {
|
||||
cwd: DISCORDJS_DIRNAME,
|
||||
env: process.env,
|
||||
stdio: "inherit"
|
||||
process.on("beforeExit", () => {
|
||||
if (exitedWithErrorProcessList.length != 0){
|
||||
console.error("Failed to run 'npm install' on:\n")
|
||||
exitedWithErrorProcessList.forEach((val)=>{
|
||||
console.error(val)
|
||||
});
|
||||
}
|
||||
console.error();
|
||||
})
|
Loading…
Reference in New Issue