fix git clone for windows

This commit is contained in:
SrGooglo 2024-01-29 01:30:25 +01:00
parent 63d3889bee
commit a0ed97d999
2 changed files with 8 additions and 14 deletions

View File

@ -10,13 +10,8 @@ import Vars from "../../vars"
const gitCMD = fs.existsSync(Vars.git_path) ? `${Vars.git_path}` : "git"
export default async (manifest, step) => {
const tmp_path = path.resolve(os.tmpdir(), `rsb_${manifest.id}_clone_${new Date().getTime()}`)
const final_path = path.resolve(manifest.install_path, step.path)
if (fs.existsSync(tmp_path)) {
fs.rmdirSync(tmp_path, { recursive: true })
}
if (!fs.existsSync(final_path)) {
fs.mkdirSync(final_path, { recursive: true })
}
@ -28,9 +23,9 @@ export default async (manifest, step) => {
console.log(`[${manifest.id}] steps.git_clone() | Cloning ${step.url}...`)
const command = `${gitCMD} clone --recurse-submodules --remote-submodules ${step.url} ${tmp_path}`
const command = `${gitCMD} clone --recurse-submodules --remote-submodules ${step.url} ${final_path}`
fs.mkdirSync(final_path, { recursive: true })
//fs.mkdirSync(final_path, { recursive: true })
await new Promise((resolve, reject) => {
ChildProcess.exec(
@ -50,12 +45,5 @@ export default async (manifest, step) => {
)
})
// move tmp_path to final_path
await fs.promises.rename(tmp_path, final_path)
if (fs.existsSync(tmp_path)) {
fs.rmdirSync(tmp_path, { recursive: true })
}
return manifest
}

View File

@ -28,6 +28,12 @@ export default async function processGenericSteps(pkg, steps) {
const stepsEntries = Object.entries(steps)
stepsEntries = stepsEntries.sort((a, b) => StepsOrders.indexOf(a[0]) - StepsOrders.indexOf(b[0]))
if (stepsEntries.length === 0) {
return pkg
}
for await (const [stepKey, stepValue] of stepsEntries) {
switch (stepKey) {
case "drive_downloads": {