Compare commits

..

3 Commits

Author SHA1 Message Date
AJ ONeal 2e9a643c0f feature: fail faster on bad createWriteStream 2021-10-18 00:55:04 -06:00
AJ ONeal dcd41a33d0 chore: add linter config 2021-10-18 00:47:39 -06:00
AJ ONeal 5f5e0b6066 bugfix: return after error callback 2021-10-18 00:47:06 -06:00
2 changed files with 35 additions and 13 deletions

22
.jshintrc Normal file
View File

@ -0,0 +1,22 @@
{
"browser": true,
"node": true,
"esversion": 11,
"curly": true,
"sub": true,
"bitwise": true,
"eqeqeq": true,
"forin": true,
"freeze": true,
"immed": true,
"latedef": "nofunc",
"nonbsp": true,
"nonew": true,
"plusplus": true,
"undef": true,
"unused": "vars",
"strict": true,
"maxdepth": 3,
"maxstatements": 100,
"maxcomplexity": 40
}

View File

@ -76,6 +76,19 @@ function setDefaults(defs) {
var req;
var finalOpts = {};
// allow specifying a file
if ('string' === typeof opts.stream) {
if (opts.debug) {
console.debug('[@root/request] creating file write stream');
}
try {
opts.stream = fs.createWriteStream(opts.stream);
} catch (e) {
cb(e);
return;
}
}
function onResponse(resp) {
var followRedirect;
@ -151,19 +164,6 @@ function setDefaults(defs) {
reject = _reject;
});
// allow specifying a file
if ('string' === typeof opts.stream) {
try {
if (opts.debug) {
console.debug(
'[@root/request] file write stream created'
);
}
opts.stream = fs.createWriteStream(opts.stream);
} catch (e) {
cb(e);
}
}
// or an existing write stream
if ('function' === typeof opts.stream.pipe) {
if (opts.debug) {