mirror of
https://github.com/ragestudio/relic.git
synced 2025-06-09 10:34:18 +00:00
added git_reset
This commit is contained in:
parent
2e381e30f6
commit
b521d44f66
30
src/main/pkg_mng/installs_steps_methods/git_reset.js
Normal file
30
src/main/pkg_mng/installs_steps_methods/git_reset.js
Normal 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)
|
||||||
|
})
|
||||||
|
}
|
@ -2,12 +2,14 @@ import ISM_DRIVE_DL from "./drive"
|
|||||||
import ISM_HTTP from "./http"
|
import ISM_HTTP from "./http"
|
||||||
import ISM_GIT_CLONE from "./git_clone"
|
import ISM_GIT_CLONE from "./git_clone"
|
||||||
import ISM_GIT_PULL from "./git_pull"
|
import ISM_GIT_PULL from "./git_pull"
|
||||||
|
import ISM_GIT_RESET from "./git_reset"
|
||||||
|
|
||||||
const InstallationStepsMethods = {
|
const InstallationStepsMethods = {
|
||||||
drive_dl: ISM_DRIVE_DL,
|
drive_dl: ISM_DRIVE_DL,
|
||||||
http: ISM_HTTP,
|
http: ISM_HTTP,
|
||||||
git_clone: ISM_GIT_CLONE,
|
git_clone: ISM_GIT_CLONE,
|
||||||
git_pull: ISM_GIT_PULL,
|
git_pull: ISM_GIT_PULL,
|
||||||
|
git_reset: ISM_GIT_RESET,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function processGenericSteps(pkg, steps) {
|
export default async function processGenericSteps(pkg, steps) {
|
||||||
@ -42,6 +44,12 @@ export default async function processGenericSteps(pkg, steps) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "git_reset": {
|
||||||
|
for await (const reset_step of stepValue) {
|
||||||
|
await InstallationStepsMethods.git_reset(pkg, reset_step)
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
throw new Error(`Unknown step: ${stepKey}`)
|
throw new Error(`Unknown step: ${stepKey}`)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user