From c63473ae17ecd7de191b90ef3bae94bb0333c8aa Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Sun, 18 Sep 2022 18:11:46 -0700 Subject: [PATCH] finish fix for #429 --- index.js | 13 ++++--------- test/429.js | 19 ++++++++++++------- test/getterIdentify.js | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/index.js b/index.js index d63c3b05..30d34971 100644 --- a/index.js +++ b/index.js @@ -72,16 +72,11 @@ function gm (source, height, color) { // must be first source formatter var inputFromStdin = this.sourceStream || this.sourceBuffer; - var ret = this.source; + var ret = inputFromStdin ? '-' : this.source; - if (inputFromStdin) { - var format = ''; - - if (this.source) { - format = this.source.split('.').pop() + ':'; - } - - ret = format + '-'; + const fileNameProvied = typeof height === 'string'; + if (inputFromStdin && fileNameProvied && /\.ico$/i.test(this.source)) { + ret = `ico:-`; } if (ret && this.sourceFrames) ret += this.sourceFrames; diff --git a/test/429.js b/test/429.js index 36847721..c6df739a 100644 --- a/test/429.js +++ b/test/429.js @@ -4,22 +4,27 @@ const fs = require('fs'); module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - // ico, buffer, stream const ico = `${__dirname}/fixtures/test.ico`; const buffer = fs.readFileSync(ico); const stream = fs.createReadStream(ico); GM(ico).size(function (err, size) { - if (err) return finish(err); - console.log('string', size); + if (err) { + err.message = 'Failed using ico filename. ' + err.message; + return finish(err); + } GM(buffer, 'img.ico').size(function (err, size) { - if (err) return finish(err); - console.log('buffer', size); + if (err) { + err.message = 'Failed using ico buffer. ' + err.message; + return finish(err); + } GM(stream, 'img.ico').size({bufferStream: true}, function (err, size) { - if (err) return finish(err); - console.log('stream', size); + if (err) { + err.message = 'Failed using ico stream. ' + err.message; + return finish(err); + } finish(); }); }); diff --git a/test/getterIdentify.js b/test/getterIdentify.js index 571814d5..08a62f57 100755 --- a/test/getterIdentify.js +++ b/test/getterIdentify.js @@ -4,7 +4,7 @@ var os = require('os') var isLinux = os.platform() === 'linux' // Be more lax with the errors if we're on linux -var errorFactor = isLinux ? 10 : 1 +var errorFactor = isLinux ? 10 : 1.1 module.exports = function (_, dir, finish, gm) { if (!gm.integration)