diff --git a/lib/spawnGPG.js b/lib/spawnGPG.js index ef37c30..ce03737 100644 --- a/lib/spawnGPG.js +++ b/lib/spawnGPG.js @@ -96,14 +96,39 @@ module.exports.streaming = function(options, args, cb) { // Go for it var gpg = spawnIt(args, cb); + let stderrData = [] + gpg.stderr.on('data', (data) => { + stderrData.push(data); + }); + if (!isDestStream) { gpg.on('close', function (code){ - cb(null); + if (code!=0) { + cb(new Error(`gpg: exit code ${code}\n${stderrData.join('')}`)); + } else { + cb(null); + } }); } else { cb(null, destStream); } + sourceStream.on('error', function(error) { + console.log(error); + }) + + destStream.on('error', function(error) { + console.log(error); + }) + + gpg.stdin.on('error', function(error) { + console.log(error); + }) + + gpg.stdout.on('error', function(error) { + console.log(error); + }) + // Pipe input file into gpg stdin; gpg stdout into output file.. sourceStream.pipe(gpg.stdin); gpg.stdout.pipe(destStream);