Socket
Socket
Sign inDemoInstall

beezlib

Package Overview
Dependencies
Maintainers
4
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

beezlib - npm Package Compare versions

Comparing version 0.9.9 to 0.9.10

79

lib/image/index.js

@@ -103,3 +103,3 @@ /**

logger.debug('cmd:', constant.PROG_PNGQUANT, args.join(' '));
logger.debug('cmd:', constant.PROG_JPEGOPTIM, args.join(' '));

@@ -235,54 +235,61 @@ var proc = spawn(constant.PROG_JPEGOPTIM, args);

var bucks = new Bucks();
bucks.empty();
if (REG_OPTIPNG_FILE.test(path) && options.optipng.use) { // optipng
bucks.add(function(err, res, next) {
self.optipng(path, options.optipng.options, function(err) {
if (err) {
logger.error('optipng error.', err);
next(err);
return;
}
logger.message('optipng:', path);
next();
});
});
}
this.optipng(path, options.optipng.options, function(err) {
if (REG_OPTIPNG_FILE.test(path) && options.pngquant.use) { // pngquant
bucks.add(function(err, res, next) {
self.pngquant(path, options.pngquant.options, function(err) { // pngquant
if (err) {
logger.error('optipng error.', err);
callback && callback(err);
return;
}
if (err) {
logger.error('pngquant error.', err);
next(err);
return;
}
logger.message('pngquant:', path);
next();
logger.message('optipng:', path);
});
});
}
if (!options.pngquant.use) {
logger.debug('skip pngquant:', path);
callback && callback(null, path);
return;
}
if (REG_JPEGOPTIM_FILE.test(path) && options.jpegoptim) { // jpegoptim
bucks.add(function(err, res, next) {
self.jpegoptim(path, options.jpegoptim.options, function(err) {
self.pngquant(path, options.pngquant.options, function(err1) { // pngquant
if (err1) {
logger.error('pngquant error.', err1);
callback && callback(err1);
if (err) {
logger.error('jpegoptim error.', err);
next(err);
return;
}
logger.message('pngquant:', path);
callback && callback(null, path);
logger.message('jpegoptim:', path);
next();
});
});
} else if (REG_JPEGOPTIM_FILE.test(path) && options.jpegoptim) { // jpegoptim
}
this.jpegoptim(path, options.jpegoptim.options, function(err) {
if (err) {
logger.error('jpegoptim error.', err);
callback && callback(err);
return;
}
logger.message('jpegoptim:', path);
callback && callback(null, path);
});
} else {
if (bucks._tasks.length === 0) {
logger.info('no match extension. path: ' + path);
callback && callback(null, path);
}
bucks.end(function(err, ress) {
callback && callback(err, path);
});
},

@@ -289,0 +296,0 @@

{
"name": "beezlib",
"version": "0.9.9",
"version": "0.9.10",
"description": "The utility library for Node.js using beez projects.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -14,3 +14,2 @@ beezlib

- [beez-foundation](https://github.com/CyberAgent/beez-foundation)
- [beez-tools](https://github.com/CyberAgent/beez-tools)

@@ -48,2 +47,4 @@ ## Requirements

- optipng
- pngquant
- jpegoptim
- imagemagick

@@ -50,0 +51,0 @@ - 画像サイズ取得

@@ -144,3 +144,3 @@ var fs = require('fs');

});
it('optim set options', function(done) {
it('optim set options #1', function(done) {
var options = {

@@ -154,2 +154,5 @@ optipng: {

options: '--strip-all'
},
pngquant: {
use: true
}

@@ -159,3 +162,2 @@ };

beezlib.image.optim('test/image/logo.jpg', options, function(err, res) {
res.should.equal("test/image/logo.jpg").be.ok;

@@ -165,3 +167,2 @@ should.not.exist(err);

beezlib.image.optim('test/image/logo.png', options, function(err1, res1) {
res1.should.equal("test/image/logo.png").be.ok;

@@ -175,2 +176,39 @@ should.not.exist(err1);

it('optim set options #2', function(done) {
var options = {optipng:{use:true},jpegoptim:{use:true},pngquant:{use:true}};
beezlib.image.optim('test/image/logo.png', options, function(err1, res1) {
res1.should.equal("test/image/logo.png").be.ok;
should.not.exist(err1);
done();
});
});
it('optim set options #3', function(done) {
var options = {optipng:{use:false},jpegoptim:{use:true},pngquant:{use:true}};
beezlib.image.optim('test/image/logo.png', options, function(err1, res1) {
res1.should.equal("test/image/logo.png").be.ok;
should.not.exist(err1);
done();
});
});
it('optim set options #4', function(done) {
var options = {optipng:{use:true},jpegoptim:{use:true},pngquant:{use:false}};
beezlib.image.optim('test/image/logo.png', options, function(err1, res1) {
res1.should.equal("test/image/logo.png").be.ok;
should.not.exist(err1);
done();
});
});
it('optim set options #5', function(done) {
var options = {optipng:{use:true},jpegoptim:{use:true},pngquant:{use:true}};
beezlib.image.optim('test/image/logo.jpg', options, function(err1, res1) {
res1.should.equal("test/image/logo.jpg").be.ok;
should.not.exist(err1);
done();
});
});
it('optim set error', function(done) {

@@ -189,3 +227,2 @@ var options = {

beezlib.image.optim('test/image/logo.error.jpg', options, function(err, res) {
should.exist(err);

@@ -192,0 +229,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc