Comparing version 1.51.0 to 1.52.0
@@ -66,3 +66,8 @@ "use strict"; | ||
const spawnedProcess = child_process_1.execFile(gitLocation, args, execOptions, function (err, stdout, stderr) { | ||
const code = err ? err.code : 0; | ||
if (!err) { | ||
resolve({ stdout, stderr, exitCode: 0 }); | ||
return; | ||
} | ||
const errWithCode = err; | ||
let code = errWithCode.code; | ||
// If the error's code is a string then it means the code isn't the | ||
@@ -74,3 +79,2 @@ // process's exit code but rather an error coming from Node's bowels, | ||
let message = err.message; | ||
let code = err.code; | ||
if (GitProcess.pathExists(path) === false) { | ||
@@ -94,11 +98,15 @@ message = 'Unable to find path to repository on disk.'; | ||
} | ||
if (code === undefined && err) { | ||
// Git has returned an output that couldn't fit in the specified buffer | ||
// as we don't know how many bytes it requires, rethrow the error with | ||
// details about what it was previously set to... | ||
if (err.message === 'stdout maxBuffer exceeded') { | ||
reject(new Error(`The output from the command could not fit into the allocated stdout buffer. Set options.maxBuffer to a larger value than ${execOptions.maxBuffer} bytes`)); | ||
} | ||
if (typeof code === 'number') { | ||
resolve({ stdout, stderr, exitCode: code }); | ||
return; | ||
} | ||
resolve({ stdout, stderr, exitCode: code }); | ||
// Git has returned an output that couldn't fit in the specified buffer | ||
// as we don't know how many bytes it requires, rethrow the error with | ||
// details about what it was previously set to... | ||
if (err.message === 'stdout maxBuffer exceeded') { | ||
reject(new Error(`The output from the command could not fit into the allocated stdout buffer. Set options.maxBuffer to a larger value than ${execOptions.maxBuffer} bytes`)); | ||
} | ||
else { | ||
reject(err); | ||
} | ||
}); | ||
@@ -105,0 +113,0 @@ if (options && options.stdin) { |
{ | ||
"name": "dugite", | ||
"version": "1.51.0", | ||
"version": "1.52.0", | ||
"description": "Elegant bindings for Git", | ||
@@ -40,12 +40,12 @@ "main": "./build/lib/index.js", | ||
"rimraf": "^2.5.4", | ||
"tar": "^2.2.1" | ||
"tar": "^4.0.2" | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "4.0.4", | ||
"@types/chai": "^4.0.5", | ||
"@types/checksum": "^0.1.30", | ||
"@types/mkdirp": "^0.5.1", | ||
"@types/mocha": "^2.2.44", | ||
"@types/node": "^8.0.47", | ||
"@types/node": "^8.0.53", | ||
"@types/progress": "^2.0.0", | ||
"@types/request": "^2.0.7", | ||
"@types/request": "^2.0.8", | ||
"@types/rimraf": "2.0.2", | ||
@@ -58,7 +58,7 @@ "byline": "^5.0.0", | ||
"mocha": "^4.0.1", | ||
"prettier": "^1.7.4", | ||
"prettier": "^1.8.2", | ||
"temp": "^0.8.3", | ||
"ts-node": "^3.0.2", | ||
"typescript": "^2.5.3" | ||
"typescript": "^2.6.1" | ||
} | ||
} |
@@ -14,8 +14,16 @@ const fs = require('fs') | ||
function extract(source, callback) { | ||
const extractor = tar.Extract({ path: config.outputPath }) | ||
.on('error', function (error) { callback(error) }) | ||
.on('end', function () { callback() }) | ||
const extractor = tar | ||
.extract({ cwd: config.outputPath }) | ||
.on('error', function(error) { | ||
callback(error) | ||
}) | ||
.on('end', function() { | ||
callback() | ||
}) | ||
fs.createReadStream(source) | ||
.on('error', function (error) { callback(error) }) | ||
fs | ||
.createReadStream(source) | ||
.on('error', function(error) { | ||
callback(error) | ||
}) | ||
.pipe(zlib.Gunzip()) | ||
@@ -25,6 +33,4 @@ .pipe(extractor) | ||
const verifyFile = function (file, callback) { | ||
const verifyFile = function(file, callback) { | ||
checksum.file(file, { algorithm: 'sha256' }, (_, hash) => { | ||
const match = hash === config.checksum | ||
@@ -40,4 +46,4 @@ | ||
const unpackFile = function (file) { | ||
extract(file, function (error) { | ||
const unpackFile = function(file) { | ||
extract(file, function(error) { | ||
if (error) { | ||
@@ -56,4 +62,4 @@ console.log('Unable to extract archive, aborting...', error) | ||
headers: { | ||
'Accept': 'application/octet-stream', | ||
'User-Agent': 'dugite', | ||
Accept: 'application/octet-stream', | ||
'User-Agent': 'dugite' | ||
} | ||
@@ -66,8 +72,8 @@ } | ||
req.on('error', function (error) { | ||
req.on('error', function(error) { | ||
if (error.code === 'ETIMEDOUT') { | ||
console.log( | ||
`A timeout has occurred while downloading '${config.source}' - check ` + | ||
`your internet connection and try again. If you are using a proxy, ` + | ||
`make sure that the HTTP_PROXY and HTTPS_PROXY environment variables are set.`, | ||
`your internet connection and try again. If you are using a proxy, ` + | ||
`make sure that the HTTP_PROXY and HTTPS_PROXY environment variables are set.`, | ||
error | ||
@@ -81,3 +87,3 @@ ) | ||
req.on('response', function (res) { | ||
req.on('response', function(res) { | ||
if (res.statusCode !== 200) { | ||
@@ -98,7 +104,7 @@ console.log(`Non-200 response returned from ${config.source} - (${res.statusCode})`) | ||
res.on('data', function (chunk) { | ||
res.on('data', function(chunk) { | ||
bar.tick(chunk.length) | ||
}) | ||
res.on('end', function () { | ||
res.on('end', function() { | ||
console.log('\n') | ||
@@ -126,2 +132,11 @@ | ||
if (fs.existsSync(config.outputPath)) { | ||
try { | ||
rimraf.sync(config.outputPath) | ||
} catch (err) { | ||
console.error(err) | ||
return | ||
} | ||
} | ||
mkdirp(config.outputPath, function(error) { | ||
@@ -133,11 +148,2 @@ if (error) { | ||
if (fs.existsSync(config.outputPath)) { | ||
try { | ||
rimraf.sync(config.outputPath) | ||
} catch (err) { | ||
console.error(err) | ||
return | ||
} | ||
} | ||
const tempFile = config.tempFile | ||
@@ -144,0 +150,0 @@ |
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
51967
725
+ Addedchownr@1.1.4(transitive)
+ Addedfs-minipass@1.2.7(transitive)
+ Addedminipass@2.9.0(transitive)
+ Addedminizlib@1.3.3(transitive)
+ Addedtar@4.4.19(transitive)
+ Addedyallist@3.1.1(transitive)
- Removedblock-stream@0.0.9(transitive)
- Removedfstream@1.0.12(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedtar@2.2.2(transitive)
Updatedtar@^4.0.2