Skip to content

Commit 27aad05

Browse files
committed
feat: depth option
1 parent 7a74737 commit 27aad05

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/clone.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const clone = async (opts: {
1717
options: ICloneOptions
1818
}) => {
1919
let { repo, dir, options } = opts
20-
const { progress } = options
20+
const { progress, depth } = options
2121
const config = await getConfig()
2222
if (!config) {
2323
return
@@ -113,7 +113,10 @@ export const clone = async (opts: {
113113
)
114114
const cloneTask = () => {
115115
return new Promise<void>((resolve, reject) => {
116-
const params = [progress && '--progress'].filter(Boolean) as string[]
116+
const params = [
117+
progress && '--progress',
118+
...(depth ? ['--depth', depth] : []),
119+
].filter(Boolean) as string[]
117120
const spawn = execa('git', ['clone', repo, targetDir, ...params], {
118121
// allow use relative path clone
119122
cwd: process.cwd(),

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const main = async () => {
1010
.command('clone <repo> [dir]')
1111
.description('clone a repository')
1212
.option('-p, --progress', 'show clone progress', false)
13+
.option('-d, --depth <size>', 'clone depth')
1314
.action((repo, dir, options) => {
1415
clone({
1516
repo,

src/interface.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ export interface ICloneOptions {
1616
* @default false
1717
*/
1818
progress: boolean
19+
/**
20+
* @default undefined
21+
*/
22+
depth?: number
1923
}

0 commit comments

Comments
 (0)