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
@ -24,11 +24,21 @@ export default async (manifest, step) => {
|
||||
|
||||
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) => {
|
||||
ChildProcess.exec(
|
||||
command,
|
||||
command.join(" "),
|
||||
{
|
||||
shell: true,
|
||||
cwd: final_path,
|
||||
@ -36,11 +46,11 @@ export default async (manifest, step) => {
|
||||
(error, out) => {
|
||||
if (error) {
|
||||
console.error(error)
|
||||
reject(error)
|
||||
} else {
|
||||
console.log(out)
|
||||
resolve()
|
||||
return reject(error)
|
||||
}
|
||||
|
||||
console.log(out)
|
||||
return resolve()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
@ -21,12 +21,22 @@ export default async (manifest, step) => {
|
||||
fs.mkdirSync(_path, { recursive: true })
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
const process = ChildProcess.exec(`${gitCMD} pull`, {
|
||||
ChildProcess.exec(
|
||||
`${gitCMD} pull`,
|
||||
{
|
||||
cwd: _path,
|
||||
shell: true,
|
||||
})
|
||||
},
|
||||
(error, out) => {
|
||||
if (error) {
|
||||
console.error(error)
|
||||
return reject(error)
|
||||
}
|
||||
|
||||
process.on("exit", resolve)
|
||||
process.on("error", reject)
|
||||
console.log(out)
|
||||
|
||||
return resolve()
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
@ -10,7 +10,65 @@ const gitCMD = fs.existsSync(Vars.git_path) ? `${Vars.git_path}` : "git"
|
||||
|
||||
export default async (manifest, step) => {
|
||||
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`, {
|
||||
id: manifest.id,
|
||||
@ -19,15 +77,23 @@ export default async (manifest, step) => {
|
||||
|
||||
console.log(`[${manifest.id}] steps.git_reset() | Reseting to ${from}...`)
|
||||
|
||||
fs.mkdirSync(_path, { recursive: true })
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
const process = ChildProcess.exec(`${gitCMD} reset --hard ${from}`, {
|
||||
ChildProcess.exec(
|
||||
`${gitCMD} reset --hard ${from}`,
|
||||
{
|
||||
cwd: _path,
|
||||
shell: true,
|
||||
})
|
||||
},
|
||||
(error, out) => {
|
||||
if (error) {
|
||||
console.error(error)
|
||||
return reject(error)
|
||||
}
|
||||
|
||||
process.on("exit", resolve)
|
||||
process.on("error", reject)
|
||||
console.log(out)
|
||||
|
||||
return resolve()
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user