added git_reset

This commit is contained in:
SrGooglo 2024-01-27 15:38:40 +01:00
parent 2e381e30f6
commit b521d44f66
2 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,30 @@
import path from "node:path"
import fs from "node:fs"
import ChildProcess from "node:child_process"
import sendToRender from "../../utils/sendToRender"
export default async (manifest, step) => {
const _path = path.resolve(manifest.install_path, step.path)
const from = step.from ?? "origin/main"
sendToRender(`pkg:update:status`, {
id: manifest.id,
statusText: `Reset from ${from}`,
})
console.log(`[${manifest.id}] steps.git_reset() | Reseting to ${from}...`)
fs.mkdirSync(_path, { recursive: true })
await new Promise((resolve, reject) => {
const process = ChildProcess.exec(`${global.GIT_PATH ?? "git"} reset --hard ${from}`, {
cwd: _path,
shell: true,
})
process.on("exit", resolve)
process.on("error", reject)
})
}

View File

@ -2,12 +2,14 @@ import ISM_DRIVE_DL from "./drive"
import ISM_HTTP from "./http"
import ISM_GIT_CLONE from "./git_clone"
import ISM_GIT_PULL from "./git_pull"
import ISM_GIT_RESET from "./git_reset"
const InstallationStepsMethods = {
drive_dl: ISM_DRIVE_DL,
http: ISM_HTTP,
git_clone: ISM_GIT_CLONE,
git_pull: ISM_GIT_PULL,
git_reset: ISM_GIT_RESET,
}
export default async function processGenericSteps(pkg, steps) {
@ -42,6 +44,12 @@ export default async function processGenericSteps(pkg, steps) {
}
break;
}
case "git_reset": {
for await (const reset_step of stepValue) {
await InstallationStepsMethods.git_reset(pkg, reset_step)
}
break;
}
default: {
throw new Error(`Unknown step: ${stepKey}`)
}