mirror of
https://github.com/ragestudio/relic.git
synced 2025-06-09 10:34:18 +00:00
use exec cb
This commit is contained in:
parent
46c77a15b0
commit
9c57a002f3
@ -20,15 +20,25 @@ export default async (manifest, step) => {
|
|||||||
statusText: `Cloning ${step.url}`,
|
statusText: `Cloning ${step.url}`,
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(`USING GIT BIN>`, gitCMD)
|
console.log(`USING GIT BIN >`, gitCMD)
|
||||||
|
|
||||||
console.log(`[${manifest.id}] steps.git_clone() | Cloning ${step.url}...`)
|
console.log(`[${manifest.id}] steps.git_clone() | Cloning ${step.url}...`)
|
||||||
|
|
||||||
const command = `${gitCMD} clone --depth ${step.depth ?? 1} --recurse-submodules --remote-submodules ${step.url} ${final_path}`
|
const command = [
|
||||||
|
gitCMD,
|
||||||
|
"clone",
|
||||||
|
//`--depth ${step.depth ?? 1}`,
|
||||||
|
//"--filter=blob:none",
|
||||||
|
//"--filter=tree:0",
|
||||||
|
"--recurse-submodules",
|
||||||
|
"--remote-submodules",
|
||||||
|
step.url,
|
||||||
|
final_path,
|
||||||
|
]
|
||||||
|
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
ChildProcess.exec(
|
ChildProcess.exec(
|
||||||
command,
|
command.join(" "),
|
||||||
{
|
{
|
||||||
shell: true,
|
shell: true,
|
||||||
cwd: final_path,
|
cwd: final_path,
|
||||||
@ -36,11 +46,11 @@ export default async (manifest, step) => {
|
|||||||
(error, out) => {
|
(error, out) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
reject(error)
|
return reject(error)
|
||||||
} else {
|
|
||||||
console.log(out)
|
|
||||||
resolve()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(out)
|
||||||
|
return resolve()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@ -21,12 +21,22 @@ export default async (manifest, step) => {
|
|||||||
fs.mkdirSync(_path, { recursive: true })
|
fs.mkdirSync(_path, { recursive: true })
|
||||||
|
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
const process = ChildProcess.exec(`${gitCMD} pull`, {
|
ChildProcess.exec(
|
||||||
cwd: _path,
|
`${gitCMD} pull`,
|
||||||
shell: true,
|
{
|
||||||
})
|
cwd: _path,
|
||||||
|
shell: true,
|
||||||
|
},
|
||||||
|
(error, out) => {
|
||||||
|
if (error) {
|
||||||
|
console.error(error)
|
||||||
|
return reject(error)
|
||||||
|
}
|
||||||
|
|
||||||
process.on("exit", resolve)
|
console.log(out)
|
||||||
process.on("error", reject)
|
|
||||||
|
return resolve()
|
||||||
|
}
|
||||||
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
@ -10,7 +10,65 @@ const gitCMD = fs.existsSync(Vars.git_path) ? `${Vars.git_path}` : "git"
|
|||||||
|
|
||||||
export default async (manifest, step) => {
|
export default async (manifest, step) => {
|
||||||
const _path = path.resolve(manifest.install_path, step.path)
|
const _path = path.resolve(manifest.install_path, step.path)
|
||||||
const from = step.from ?? "origin/main"
|
const from = step.from ?? "HEAD"
|
||||||
|
|
||||||
|
if (!fs.existsSync(_path)) {
|
||||||
|
fs.mkdirSync(_path, { recursive: true })
|
||||||
|
}
|
||||||
|
|
||||||
|
sendToRender(`pkg:update:status`, {
|
||||||
|
id: manifest.id,
|
||||||
|
statusText: `Fetching from origin...`,
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log(`[${manifest.id}] steps.git_reset() | Fetching from origin...`)
|
||||||
|
|
||||||
|
// fetch from origin
|
||||||
|
await new Promise((resolve, reject) => {
|
||||||
|
ChildProcess.exec(
|
||||||
|
`${gitCMD} fetch origin`,
|
||||||
|
{
|
||||||
|
cwd: _path,
|
||||||
|
shell: true,
|
||||||
|
},
|
||||||
|
(error, out) => {
|
||||||
|
if (error) {
|
||||||
|
console.error(error)
|
||||||
|
return reject(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(out)
|
||||||
|
return resolve()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
sendToRender(`pkg:update:status`, {
|
||||||
|
id: manifest.id,
|
||||||
|
statusText: `Cleaning untracked files...`,
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log(`[${manifest.id}] steps.git_reset() | Cleaning...`)
|
||||||
|
|
||||||
|
await new Promise((resolve, reject) => {
|
||||||
|
ChildProcess.exec(
|
||||||
|
`${gitCMD} clean -df`,
|
||||||
|
{
|
||||||
|
cwd: _path,
|
||||||
|
shell: true,
|
||||||
|
},
|
||||||
|
(error, out) => {
|
||||||
|
if (error) {
|
||||||
|
console.error(error)
|
||||||
|
return reject(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(out)
|
||||||
|
|
||||||
|
return resolve()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
sendToRender(`pkg:update:status`, {
|
sendToRender(`pkg:update:status`, {
|
||||||
id: manifest.id,
|
id: manifest.id,
|
||||||
@ -19,15 +77,23 @@ export default async (manifest, step) => {
|
|||||||
|
|
||||||
console.log(`[${manifest.id}] steps.git_reset() | Reseting to ${from}...`)
|
console.log(`[${manifest.id}] steps.git_reset() | Reseting to ${from}...`)
|
||||||
|
|
||||||
fs.mkdirSync(_path, { recursive: true })
|
|
||||||
|
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
const process = ChildProcess.exec(`${gitCMD} reset --hard ${from}`, {
|
ChildProcess.exec(
|
||||||
cwd: _path,
|
`${gitCMD} reset --hard ${from}`,
|
||||||
shell: true,
|
{
|
||||||
})
|
cwd: _path,
|
||||||
|
shell: true,
|
||||||
|
},
|
||||||
|
(error, out) => {
|
||||||
|
if (error) {
|
||||||
|
console.error(error)
|
||||||
|
return reject(error)
|
||||||
|
}
|
||||||
|
|
||||||
process.on("exit", resolve)
|
console.log(out)
|
||||||
process.on("error", reject)
|
|
||||||
|
return resolve()
|
||||||
|
}
|
||||||
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user