Socket
Socket
Sign inDemoInstall

gulp-svgmin

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-svgmin - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

13

index.js

@@ -10,2 +10,3 @@ /* jshint node:true */

var PLUGIN_NAME = 'gulp-svgmin';

@@ -24,3 +25,3 @@ // File level transform function

if (err) {
cb(gutil.PluginError('svgmin', err));
cb(gutil.PluginError(PLUGIN_NAME, err));
}

@@ -31,3 +32,3 @@

if (result.error) {
cb(gutil.PluginError('svgmin', result.error));
cb(gutil.PluginError(PLUGIN_NAME, result.error));
}

@@ -47,2 +48,8 @@

stream._transform = function(file, unused, done) {
// When null just pass through
if(file.isNull()) {
stream.push(file); done();
return;
}
if (file.isStream()) {

@@ -56,3 +63,3 @@ file.contents = file.contents.pipe(

if (result.error) {
stream.emit('error', gutil.PluginError('svgmin', result.error));
stream.emit('error', gutil.PluginError(PLUGIN_NAME, result.error));
}

@@ -59,0 +66,0 @@ file.contents = new Buffer(result.data);

{
"name": "gulp-svgmin",
"version": "0.3.0",
"version": "0.4.0",
"description": "Minify SVG files with gulp.",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -22,109 +22,137 @@ /* jshint node: true */

describe('gulp-svgmin', function() {
it('should minify svg with svgo', function(cb) {
var stream = svgmin();
stream.on('data', function(data) {
expect(String(data.contents)).to.equal(compressed);
cb();
});
describe('with null contents', function() {
stream.write(new gutil.File({
contents: new Buffer(raw)
}));
});
it('should let null files pass through', function(done) {
it('should honor disabling plugins, such as keeping the doctype', function(cb) {
var stream = svgmin([{
removeDoctype: false
}]);
var s = svgmin(),
n = 0;
s.pipe(es.through(function(file) {
expect(file.path).to.equal('bibabelula.md');
expect(file.contents).to.equal(null);
n++;
}, function() {
expect(n).to.equal(1);
done();
}));
s.write(new gutil.File({
path: 'bibabelula.md',
contents: null
}));
s.end();
stream.on('data', function(data) {
expect(String(data.contents)).to.have.string(doctype);
cb();
});
stream.write(new gutil.File({
contents: new Buffer(raw)
}));
});
it('should allow disabling multiple plugins', function(cb) {
var stream = svgmin([{
removeDoctype: false
}, {
removeComments: false
}]);
describe('in buffer mode', function() {
stream.on('data', function(data) {
expect(String(data.contents)).to.have.string(doctype).and.to.have.string('test comment');
cb();
});
it('should minify svg with svgo', function(cb) {
var stream = svgmin();
stream.write(new gutil.File({
contents: new Buffer(raw)
}));
});
});
stream.on('data', function(data) {
expect(String(data.contents)).to.equal(compressed);
cb();
});
describe('gulp-svgmin in stream mode', function() {
it('should minify svg with svgo', function(cb) {
var stream = svgmin();
var fakeFile = new gutil.File({
contents: new Stream()
stream.write(new gutil.File({
contents: new Buffer(raw)
}));
});
stream.on('data', function(data) {
data.contents.pipe(es.wait(function(err, data) {
expect(data).to.equal(compressed);
it('should honor disabling plugins, such as keeping the doctype', function(cb) {
var stream = svgmin([{
removeDoctype: false
}]);
stream.on('data', function(data) {
expect(String(data.contents)).to.have.string(doctype);
cb();
});
stream.write(new gutil.File({
contents: new Buffer(raw)
}));
});
stream.write(fakeFile);
fakeFile.contents.write(raw);
fakeFile.contents.end();
});
it('should allow disabling multiple plugins', function(cb) {
var stream = svgmin([{
removeDoctype: false
}, {
removeComments: false
}]);
it('should honor disabling plugins, such as keeping the doctype', function(cb) {
var stream = svgmin([{
removeDoctype: false
}]);
var fakeFile = new gutil.File({
contents: new Stream()
});
stream.on('data', function(data) {
expect(String(data.contents)).to.have.string(doctype).and.to.have.string('test comment');
cb();
});
stream.on('data', function(data) {
data.contents.pipe(es.wait(function(err, data) {
expect(data).to.have.string(doctype);
cb();
stream.write(new gutil.File({
contents: new Buffer(raw)
}));
});
stream.write(fakeFile);
fakeFile.contents.write(raw);
fakeFile.contents.end();
});
it('should allow disabling multiple plugins', function(cb) {
var stream = svgmin([{
removeDoctype: false
}, {
removeComments: false
}]);
var fakeFile = new gutil.File({
contents: new Stream()
describe('stream mode', function() {
it('should minify svg with svgo', function(cb) {
var stream = svgmin();
var fakeFile = new gutil.File({
contents: new Stream()
});
stream.on('data', function(data) {
data.contents.pipe(es.wait(function(err, data) {
expect(data).to.equal(compressed);
cb();
}));
});
stream.write(fakeFile);
fakeFile.contents.write(raw);
fakeFile.contents.end();
});
it('should honor disabling plugins, such as keeping the doctype', function(cb) {
var stream = svgmin([{
removeDoctype: false
}]);
var fakeFile = new gutil.File({
contents: new Stream()
});
stream.on('data', function(data) {
data.contents.pipe(es.wait(function(err, data) {
expect(data).to.have.string(doctype);
cb();
}));
});
stream.write(fakeFile);
fakeFile.contents.write(raw);
fakeFile.contents.end();
});
stream.on('data', function(data) {
data.contents.pipe(es.wait(function(err, data) {
expect(data).to.have.string(doctype).and.to.have.string('test comment');
cb();
}));
it('should allow disabling multiple plugins', function(cb) {
var stream = svgmin([{
removeDoctype: false
}, {
removeComments: false
}]);
var fakeFile = new gutil.File({
contents: new Stream()
});
stream.on('data', function(data) {
data.contents.pipe(es.wait(function(err, data) {
expect(data).to.have.string(doctype).and.to.have.string('test comment');
cb();
}));
});
stream.write(fakeFile);
fakeFile.contents.write(raw);
fakeFile.contents.end();
});
stream.write(fakeFile);
fakeFile.contents.write(raw);
fakeFile.contents.end();
});
});
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