New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gulp-csso

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-csso - npm Package Compare versions

Comparing version 3.0.1 to 4.0.0

6

CHANGELOG.md

@@ -0,1 +1,7 @@

# 4.0.0 (November 14, 2019)
* Update CSSO to [^4.0.0](https://github.com/css/csso/releases/tag/v4.0.0)
* Plugin never produce a parse error, but drops bad parts of CSS instead
* Drop support for Node.js < 8
# 3.0.1

@@ -2,0 +8,0 @@

80

index.js
'use strict';
var csso = require('csso'),
PluginError = require('plugin-error'),
Transform = require('stream').Transform,
applySourceMap = require('vinyl-sourcemaps-apply');
const csso = require('csso');
const PluginError = require('plugin-error');
const { Transform } = require('stream');
const applySourceMap = require('vinyl-sourcemaps-apply');
function processParseError(source, filename, details, message) {
function formatLines(start, end) {
return lines.slice(start, end).map(function(line, idx) {
var num = String(start + idx + 1);
while (num.length < maxNumLength) {
num = ' ' + num;
}
return num + ' |' + line;
}).join('\n');
}
var lines = source.split(/\n|\r\n?|\f/);
var column = details.column;
var line = details.line;
var startLine = Math.max(1, line - 2);
var endLine = Math.min(line + 2, lines.length + 1);
var maxNumLength = Math.max(4, String(endLine).length) + 1;
return [
'CSS parse error ' + filename + ': ' + message,
formatLines(startLine - 1, line),
new Array(column + maxNumLength + 2).join('-') + '^',
formatLines(line, endLine)
].join('\n');
}
module.exports = function (options) {
var stream = new Transform({ objectMode: true });
const stream = new Transform({ objectMode: true });
stream._transform = function (file, encoding, cb) {
function handleError(error) {
if ('parseError' in error) {
error = processParseError(source, inputFile, error.parseError, error.message);
}
cb(new PluginError('gulp-csso', error));
}
if (file.isNull()) {

@@ -53,28 +17,22 @@ return cb(null, file);

if (file.isStream()) {
return handleError('Streaming not supported');
return cb(new PluginError('gulp-csso', 'Streaming not supported'));
}
var inputFile = file.relative;
var source = String(file.contents);
var cssoOptions = {
filename: inputFile,
if (options === undefined || typeof options === 'boolean') {
// for backward capability
options = {
restructure: !options
};
}
const inputFile = file.relative;
const source = String(file.contents);
const cssoOptions = Object.assign({
sourceMap: Boolean(file.sourceMap),
restructure: true,
debug: false
};
}, options, { filename: inputFile }); // filename can't be overridden
if (options === undefined || typeof options === 'boolean') {
// for backward capability
cssoOptions.restructure = !options;
} else if (options) {
// extend default csso options
for (var name in options) {
if (options.hasOwnProperty(name) && name !== 'filename') {
cssoOptions[name] = options[name];
}
}
}
try {
var result = csso.minify(source, cssoOptions);
const result = csso.minify(source, cssoOptions);

@@ -90,3 +48,3 @@ if (result.map) {

} catch(error) {
handleError(error);
cb(new PluginError('gulp-csso', error));
}

@@ -93,0 +51,0 @@ };

{
"name": "gulp-csso",
"version": "3.0.1",
"version": "4.0.0",
"description": "Minify CSS with CSSO.",

@@ -26,12 +26,15 @@ "license": "MIT",

"dependencies": {
"csso": "^3.0.0",
"plugin-error": "^0.1.2",
"csso": "^4.0.0",
"plugin-error": "^1.0.0",
"vinyl-sourcemaps-apply": "^0.2.1"
},
"devDependencies": {
"tap-spec": "^4.1.0",
"tap-spec": "^5.0.0",
"tape": "^4.2.1",
"vinyl": "^2.1.0"
},
"main": "index.js"
"main": "index.js",
"engines": {
"node": ">=8.0.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