Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-minify-css

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-minify-css - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

43

index.js
var es = require('event-stream'),
cleanCSS = require('clean-css'),
clone = require('clone');
clone = require('clone'),
BufferStreams = require('bufferstreams'),
gutil = require('gulp-util');
module.exports = function(opt){
// File level transform function
function minifyCSSTransform(opt) {
// Return a callback function handling the buffered content
return function(err, buf, cb) {
// Handle any error
if(err) cb(gutil.PluginError('minify-css', err));
// Use the buffered content
buf = Buffer(cleanCSS.process(String(buf), opt));
// Bring it back to streams
cb(null, buf);
}
}
// Plugin function
function minifyCSSGulp(opt){
if (!opt) opt = {};
function modifyContents(file, cb){
if(file.isNull()) return cb(null, file);
if(file.isStream()) {
file.contents = file.contents.pipe(new BufferStreams(minifyCSSTransform(opt)));
return cb(null, file);
}
var newFile = clone(file);

@@ -15,3 +45,10 @@

}
return es.map(modifyContents);
}
}
// Export the file level transform function for other plugins usage
minifyCSSGulp.fileTransform = minifyCSSTransform;
// Export the plugin main function
module.exports = minifyCSSGulp;

24

package.json
{
"name": "gulp-minify-css",
"description": "Minify css with clean-css.",
"version": "0.1.0",
"version": "0.2.0",
"repository": "https://github.com/jonathanepollack/gulp-minify-css.git",
"homepage": "https://github.com/jonathanepollack/gulp-minify-css",
"keywords": [
"gulpplugin"
],
"keywords": [
"gulpplugin"
],
"main": "./index.js",
"dependencies": {
"event-stream": "~3.0.16",
"clean-css": "~1.0.12",
"clone": "~0.1.9"
"event-stream": "~3.0.16",
"clean-css": "~1.0.12",
"clone": "~0.1.9",
"bufferstreams": "0.0.1",
"gulp-util": "~2.2.5"
},
"engines": {
"node": ">= 0.8"
},
"node": ">= 0.10"
},
"scripts": {

@@ -25,3 +27,3 @@ "test": "mocha"

"chai": "~1.7.2",
"gulp": "~0.1.0"
"gulp": "~3.2.0"
},

@@ -33,2 +35,2 @@ "licenses": [

]
}
}

@@ -14,3 +14,3 @@ [![Build Status](https://travis-ci.org/jonathanepollack/gulp-minify-css.png?branch=master)](https://travis-ci.org/jonathanepollack/gulp-minify-css)

<td>Node Version</td>
<td>>= 0.8</td>
<td>>= 0.10</td>
</tr>

@@ -17,0 +17,0 @@ </table>

@@ -6,2 +6,3 @@ var gulp = require('gulp'),

es = require('event-stream'),
Stream = require('stream'),
path = require('path'),

@@ -13,22 +14,48 @@ fs = require('fs');

describe('gulp-minify-css minification', function() {
var filename = path.join(__dirname, './fixture/index.css');
it('should minify my files', function(done) {
gulp.file(filename)
.pipe(minifyCSS())
.pipe(es.map(function(file){
var source = fs.readFileSync(filename),
expected = cleanCSS.process(source.toString());
expect(expected).to.be.equal(file.contents.toString());
done();
}));
describe('with buffers', function() {
var filename = path.join(__dirname, './fixture/index.css');
it('should minify my files', function(done) {
gulp.src(filename)
.pipe(minifyCSS())
.pipe(es.map(function(file){
var source = fs.readFileSync(filename),
expected = cleanCSS.process(source.toString());
expect(expected).to.be.equal(file.contents.toString());
done();
}));
});
it('should return file.contents as a buffer', function(done) {
gulp.src(filename)
.pipe(minifyCSS())
.pipe(es.map(function(file) {
expect(file.contents).to.be.an.instanceof(Buffer);
done();
}));
});
});
describe('with streams', function() {
var filename = path.join(__dirname, './fixture/index.css');
it('should minify my files', function(done) {
gulp.src(filename, {buffer: false})
.pipe(minifyCSS())
.pipe(es.map(function(file){
var source = fs.readFileSync(filename),
expected = cleanCSS.process(source.toString());
file.contents.pipe(es.wait(function(err, data) {
expect(expected).to.be.equal(data);
done();
}));
}));
});
it('should return file.contents as a buffer', function(done) {
gulp.file(filename)
.pipe(minifyCSS())
.pipe(es.map(function(file) {
expect(file.contents).to.be.an.instanceof(Buffer);
done();
}));
it('should return file.contents as a buffer', function(done) {
gulp.src(filename, {buffer: false})
.pipe(minifyCSS())
.pipe(es.map(function(file) {
expect(file.contents).to.be.an.instanceof(Stream);
done();
}));
});
});
});
});

Sorry, the diff of this file is not supported yet

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