diff --git a/README.md b/README.md index 1920e2e..54b816c 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ interface GitlyOptions { * repositories as long as the local git installation has access) * ``` */ - backend?: 'axios' | 'git', + backend?: 'axios' | 'git' /** * Set the git options (default: undefined) */ diff --git a/src/utils/clone.ts b/src/utils/clone.ts index 3446f9c..87e735e 100644 --- a/src/utils/clone.ts +++ b/src/utils/clone.ts @@ -42,10 +42,13 @@ export default async function clone( } // Prevent second order command injection - + const depth = options?.git?.depth || 1 - if (repository.includes('--upload-pack') || directory.includes('--upload-pack')) { + if ( + repository.includes('--upload-pack') || + directory.includes('--upload-pack') + ) { throw new GitlyCloneError('Invalid argument') } @@ -59,7 +62,6 @@ export default async function clone( throw new GitlyCloneError('Invalid argument') } - const child = spawn('git', [ 'clone', '--depth', @@ -69,9 +71,7 @@ export default async function clone( ]) await new Promise((resolve, reject) => { - child.on('error', (reason) => - reject(new GitlyCloneError(reason.message)) - ) + child.on('error', (reason) => reject(new GitlyCloneError(reason.message))) child.on('close', (code) => { /* istanbul ignore next */ if (code === 0) { diff --git a/src/utils/download.ts b/src/utils/download.ts index 0e2fb82..42672be 100644 --- a/src/utils/download.ts +++ b/src/utils/download.ts @@ -34,7 +34,7 @@ export default async function download( /* istanbul ignore next */ rm(archivePath) } - + return fetch(url, archivePath, options) } let order = [local, remote] diff --git a/src/utils/parse.ts b/src/utils/parse.ts index dbb3eb0..ef95c89 100644 --- a/src/utils/parse.ts +++ b/src/utils/parse.ts @@ -59,7 +59,6 @@ function normalizeURL(url: string, options: GitlyOptions) { let updatedHost = host || '' if (isNotProtocol && hasHost) { - // Matches host:owner/repo const hostMatch = url.match(/([\S]+):.+/) updatedHost = hostMatch ? hostMatch[1] : ''