Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Takeshi committed Feb 16, 2024
1 parent d3b44f6 commit bc50d55
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/utils/clone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,17 @@ export default async function clone(
let order: (() => Promise<boolean | string>)[] = []

const local = async () => exists(path)
const remote = async () => {
// Use the git command to clone the repository
// but promisify cross-spawn to handle the output
return new Promise<string>((resolve, reject) => {
const child = spawn('git', ['clone', info.href, path])
const remote = async () => new Promise<string>((resolve, reject) => {
const child = spawn('git', ['clone', info.href, path])

child.on('close', (code) => {
if (code === 0) {
resolve(path)
} else {
reject(new GitlyCloneError('Failed to clone the repository'))
}
})
child.on('close', (code) => {
if (code === 0) {
resolve(path)
} else {
reject(new GitlyCloneError('Failed to clone the repository'))
}
})
}
})


if ((await isOffline()) || options.cache) {
Expand Down

0 comments on commit bc50d55

Please sign in to comment.