Comparing version 0.14.1 to 0.14.2
@@ -0,1 +1,5 @@ | ||
### v0.14.2 (2023-12-18) | ||
- [Account for gifsicle outputting warnings on stderr.](https://github.com/papandreou/impro/commit/e8339609941e03d543b0f1af2d207a058438d140) ([Alex J Burke](mailto:alex@alexjeffburke.com)) | ||
### v0.14.1 (2023-12-17) | ||
@@ -2,0 +6,0 @@ |
{ | ||
"name": "impro", | ||
"version": "0.14.1", | ||
"version": "0.14.2", | ||
"description": "Image processing engine", | ||
@@ -5,0 +5,0 @@ "author": "Andreas Lind <andreaslindpetersen@gmail.com>", |
@@ -79,3 +79,7 @@ const errors = require('../errors'); | ||
if (args.length > 0) { | ||
pipeline._attach(new StdinoutStream('gifsicle', binPath, args)); | ||
pipeline._attach( | ||
new StdinoutStream('gifsicle', binPath, args, { | ||
filterStderr: (line) => !line.startsWith('gifsicle: warning:'), | ||
}) | ||
); | ||
seenOperationThatMustComeBeforeExtract = false; | ||
@@ -82,0 +86,0 @@ if (allGifsicleArgs.length > 0) allGifsicleArgs.push(';'); |
@@ -6,4 +6,8 @@ const childProcess = require('child_process'); | ||
function noopFilterStderr() { | ||
return true; | ||
} | ||
module.exports = class StdinoutStream extends Stream.Transform { | ||
constructor(name, binary, args) { | ||
constructor(name, binary, args, options) { | ||
super(); | ||
@@ -14,2 +18,3 @@ | ||
this.errorline = null; | ||
this.filterStderr = null; | ||
this.logger = null; | ||
@@ -22,2 +27,9 @@ this.process = null; | ||
this.logger = debug(name); | ||
options = options || {}; | ||
if (typeof options.filterStderr === 'function') { | ||
this.filterStderr = options.filterStderr; | ||
} else { | ||
this.filterStderr = noopFilterStderr; | ||
} | ||
} | ||
@@ -87,10 +99,24 @@ | ||
const decodeStderr = (line) => { | ||
let errorMessage; | ||
try { | ||
errorMessage = line.toString(); | ||
} catch (e) { | ||
return 'undecodeable output on stderr'; | ||
} | ||
if (!errorMessage) { | ||
// empty line output on stderr => ignore | ||
return null; | ||
} else if (!this.filterStderr(errorMessage)) { | ||
// filter indicated a non-error => ignore | ||
return null; | ||
} | ||
return errorMessage; | ||
}; | ||
this.process.stderr.on('data', (line) => { | ||
if (this.errorline === null) { | ||
if (this.errorline !== null) { | ||
// ignore | ||
} else if ((this.errorline = decodeStderr(line)) !== null) { | ||
this.hasErrored = true; | ||
try { | ||
this.errorline = line.toString(); | ||
} catch (e) { | ||
this.errorline = 'undecodeable error'; | ||
} | ||
} | ||
@@ -97,0 +123,0 @@ }); |
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
97891
2136