Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ The git repo is shallowly cloned by default. To make a complete clone, set `opti
When the operation is finished, `callback` is called. The first argument to `callback` is either
`null` or an `Error` object if an error occurred.

### `gitPullOrClone.async(url, outPath[, options])`

Work as same as `gitPullOrClone(url, outPath[, options], callback)` but handle callback as async function

## License

MIT. Copyright (c) [Feross Aboukhadijeh](http://feross.org).
14 changes: 14 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
interface Options {
depth?: number
}

type Callback = (error?: Error) => void

type GitPullOrClone = {
(url: string, outPath: string, opts?: Options | Callback, cb?: Callback): void
async: (url: string, outPath: string, opts?: Options) => Promise<void>
}

const gitPullOrClone: GitPullOrClone

export = gitPullOrClone
17 changes: 17 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,20 @@ function spawn (command, args, opts, cb) {
})
return child
}

gitPullOrClone.async = function(url, outPath, opts) {
return new Promise(
(resolve, reject) =>
gitPullOrClone(
url,
outPath,
opts || {},
err => {
if (!err) {
resolve()
}
reject(err)
}
)
)
}