Added main.js file detecting
This commit is contained in:
parent
e8a3c7fc41
commit
cc53a210ae
2 changed files with 32 additions and 15 deletions
14
preload.js
14
preload.js
|
@ -1,6 +1,7 @@
|
|||
const { contextBridge } = require("electron")
|
||||
const { resolve, join } = require("path")
|
||||
const { exec } = require("child_process")
|
||||
const { promises, constants } = require("fs")
|
||||
|
||||
const execWithPromise = async (command, options) =>
|
||||
new Promise(async (resolve, reject) =>
|
||||
|
@ -11,16 +12,23 @@ const execWithPromise = async (command, options) =>
|
|||
|
||||
contextBridge.exposeInMainWorld("installPackage", async (link) => {
|
||||
const packagesPath = resolve(__dirname, "..")
|
||||
const packagePath = join(packagesPath, link[7])
|
||||
try {
|
||||
await execWithPromise(`git clone ${link[0]}`, {
|
||||
cwd: packagesPath,
|
||||
})
|
||||
|
||||
await execWithPromise("pnpm i --production", {
|
||||
cwd: join(packagesPath, link[7]),
|
||||
cwd: packagePath,
|
||||
})
|
||||
|
||||
try {
|
||||
await promises.access(join(packagePath, "main.js"), constants.F_OK)
|
||||
return "Main.js file detected: Please quit Discord from the system tray"
|
||||
} catch (error) {
|
||||
return "Please reload discord with Ctrl+R"
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
return true
|
||||
return console.error(error)
|
||||
}
|
||||
})
|
||||
|
|
Reference in a new issue