graceful-git
Advanced tools
Comparing version 3.0.2 to 3.1.0
17
index.js
'use strict' | ||
const which = require('@zkochan/which'); | ||
const execa = require('execa') | ||
const retry = require('retry') | ||
const execGit = execa.bind(null, 'git') | ||
let gitLocation | ||
@@ -14,3 +15,6 @@ const RETRY_OPTIONS = { | ||
module.exports = (args, opts) => { | ||
module.exports = gracefulGit | ||
module.exports.noRetry = noRetry | ||
async function gracefulGit (args, opts) { | ||
opts = opts || {} | ||
@@ -20,4 +24,3 @@ const operation = retry.operation(Object.assign({}, RETRY_OPTIONS, opts)) | ||
operation.attempt(currentAttempt => { | ||
execGit(args, {cwd: opts.cwd || process.cwd()}) | ||
.then(resolve) | ||
noRetry(args, opts).then(resolve) | ||
.catch(err => { | ||
@@ -32,1 +35,7 @@ if (operation.retry(err)) { | ||
} | ||
async function noRetry (args, opts) { | ||
opts = opts || {} | ||
gitLocation = gitLocation || await which('git') | ||
return execa(gitLocation, args, {cwd: opts.cwd || process.cwd()}) | ||
} |
{ | ||
"name": "graceful-git", | ||
"version": "3.0.2", | ||
"version": "3.1.0", | ||
"description": "Executes git commands gracefully. Retries them on errors", | ||
@@ -38,2 +38,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"@zkochan/which": "^2.0.3", | ||
"execa": "^5.0.0", | ||
@@ -46,4 +47,4 @@ "retry": "^0.12.0" | ||
"package-preview": "3.0.0", | ||
"tape": "^5.0.1" | ||
"tape": "^5.1.1" | ||
} | ||
} |
# graceful-git | ||
> Executes git commands gracefully. Retries on errors | ||
> Executes Git commands gracefully. Retries on errors | ||
Git is called by absolute path to avoid binary planting attacks on Windows. | ||
<!--@shields('npm')--> | ||
@@ -42,4 +44,8 @@ [![npm version](https://img.shields.io/npm/v/graceful-git.svg)](https://www.npmjs.com/package/graceful-git) | ||
### `git.noRetry(args, [opts]) => Promise` | ||
Same as `git()` but without retries. | ||
## License | ||
[MIT](./LICENSE) © [Zoltan Kochan](https://www.kochan.io) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4268
33
51
3
4
+ Added@zkochan/which@^2.0.3
+ Added@zkochan/which@2.0.3(transitive)