diff --git a/src/utils/clone.ts b/src/utils/clone.ts index 7ac3c02..e735cde 100644 --- a/src/utils/clone.ts +++ b/src/utils/clone.ts @@ -1,5 +1,6 @@ import GitlyOptions from '../interfaces/options' import { getArchivePath } from './archive' +import { GitlyCloneError } from './error' import execute from './execute' import exists from './exists' import { isOffline } from './offline' @@ -20,8 +21,19 @@ export default async function clone( const local = async () => exists(path) const remote = async () => { - const result = spawn.sync('git', ['clone', info.href, path]) - return result.status === 0 + // Use the git command to clone the repository + // but promisify cross-spawn to handle the output + return new Promise((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')) + } + }) + }) }