Fix error
This commit is contained in:
parent
5ddddcfe3e
commit
4811d6d77a
2 changed files with 16 additions and 6 deletions
14
preload.js
14
preload.js
|
@ -1,6 +1,7 @@
|
||||||
const { contextBridge } = require("electron")
|
const { contextBridge } = require("electron")
|
||||||
const { resolve, join } = require("path")
|
const { resolve, join } = require("path")
|
||||||
const { promises, constants } = require("fs")
|
const { promises, constants } = require("fs")
|
||||||
|
const { access } = promises
|
||||||
|
|
||||||
const exec = require("util").promisify(require("child_process").exec)
|
const exec = require("util").promisify(require("child_process").exec)
|
||||||
|
|
||||||
|
@ -16,18 +17,27 @@ contextBridge.exposeInMainWorld("installPackage", async (link) => {
|
||||||
cwd: packagesPath,
|
cwd: packagesPath,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
try {
|
||||||
|
await access(join(packagePath, "package.json"), constants.F_OK)
|
||||||
|
try {
|
||||||
await exec(`pnpm i --production`, {
|
await exec(`pnpm i --production`, {
|
||||||
cwd: packagePath,
|
cwd: packagePath,
|
||||||
})
|
})
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await promises.access(join(packagePath, "main.js"), constants.F_OK)
|
await access(join(packagePath, "main.js"), constants.F_OK)
|
||||||
return {
|
return {
|
||||||
reloadMessage:
|
reloadMessage:
|
||||||
"Main.js file detected: Please quit Discord from the system tray",
|
"Main.js file detected: Please quit Discord from the system tray",
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return { reloadMessage: "Please reload discord with Ctrl+R" }
|
return {
|
||||||
|
reloadMessage: "Please reload discord with Ctrl+R",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return { error }
|
return { error }
|
||||||
|
|
|
@ -120,7 +120,7 @@ export default new (class PackageDownloader {
|
||||||
if (
|
if (
|
||||||
props?.message &&
|
props?.message &&
|
||||||
props.channel &&
|
props.channel &&
|
||||||
props.channel.id == "899717501120806963"
|
props.channel?.id == "899717501120806963"
|
||||||
)
|
)
|
||||||
args[0].children.unshift(React.createElement(Button))
|
args[0].children.unshift(React.createElement(Button))
|
||||||
|
|
||||||
|
|
Reference in a new issue