Dont call 'next' callback twice, include error message if zip don't exit normally
This commit is contained in:
parent
4b98b7056a
commit
884d3aea0a
@ -59,15 +59,24 @@ ShpFormat.prototype.toSHP = function (options, callback) {
|
|||||||
|
|
||||||
var child = spawn(zip, ['-qrj', zipfile, outdirpath ]);
|
var child = spawn(zip, ['-qrj', zipfile, outdirpath ]);
|
||||||
|
|
||||||
child.on('exit', function(code) {
|
var stderrData = [];
|
||||||
//console.log("Zip complete, zip return code was " + code);
|
child.stderr.setEncoding('utf8');
|
||||||
if (code) {
|
child.stderr.on('data', function (data) {
|
||||||
next(new Error("Zip command return code " + code));
|
stderrData.push(data);
|
||||||
//res.statusCode = 500;
|
|
||||||
}
|
|
||||||
next(null);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
child.on('exit', function(code) {
|
||||||
|
if (code !== 0) {
|
||||||
|
var errMessage = 'Zip command return code ' + code;
|
||||||
|
if (stderrData.length) {
|
||||||
|
errMessage += ', Error: ' + stderrData.join('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
return next(new Error(errMessage));
|
||||||
|
}
|
||||||
|
|
||||||
|
return next();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
function cleanupDir(topError) {
|
function cleanupDir(topError) {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user