Skip to content

Commit

Permalink
finish fix for #429
Browse files Browse the repository at this point in the history
  • Loading branch information
aheckmann committed Sep 19, 2022
1 parent a7f20dc commit c63473a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
13 changes: 4 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 12 additions & 7 deletions test/429.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/getterIdentify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c63473a

Please sign in to comment.