handle "pkg_auto_update_on_execute" setting

This commit is contained in:
SrGooglo 2024-01-25 23:17:43 +01:00
parent e7605dc80a
commit be5b1ca99a

View File

@ -7,6 +7,8 @@ import initManifest from "../../utils/initManifest"
import parseStringVars from "../../utils/parseStringVars"
import sendToRender from "../../utils/sendToRender"
import UpdateCMD from "./update"
export default async function execute(pkg_id, { force = false } = {}) {
let pkg = await getInstalledPackages(pkg_id)
@ -36,8 +38,10 @@ export default async function execute(pkg_id, { force = false } = {}) {
if (pkg._original_manifest) {
if ((pkg._original_manifest.version !== pkg.version) && !force) {
console.log(`[${pkg_id}] execute() | Update available (${pkg._original_manifest.version} -> ${pkg.version}). Aborting...`,)
console.log(pkg._original_manifest)
if (global.SettingsStore.get("pkg_auto_update_on_execute") === true) {
await UpdateCMD(pkg_id)
} else {
sendToRender("pkg:update_available", {
manifest: pkg._original_manifest,
current_version: pkg._original_manifest.version,
@ -53,6 +57,7 @@ export default async function execute(pkg_id, { force = false } = {}) {
}
}
}
}
if (typeof pkg.after_execute === "function") {
await pkg.after_execute(pkg)