n is not a function

This commit is contained in:
Henry Hiles 2022-04-26 06:32:31 -04:00
parent a238ab299a
commit a9b6d3c2a5
4 changed files with 137 additions and 14 deletions

View file

@ -1 +1,28 @@
// Do something in the preload of discord.
const { contextBridge } = require("electron")
const { resolve, join } = require("path")
const { exec } = require("child_process")
const execWithPromise = async (command, options) =>
new Promise(async (resolve, reject) =>
exec(command, options, (err, stout, sterr) =>
err ? reject(err, sterr) : resolve(stout)
)
)
contextBridge.exposeInMainWorld("package", {
install: async (link) => {
const packagesPath = resolve(__dirname, "..")
try {
await execWithPromise(`git clone ${link[0]}`, {
cwd: packagesPath,
})
await execWithPromise("pnpm i --production", {
cwd: join(packagesPath, link[7]),
})
} catch (error) {
console.error(error)
return true
}
},
})