Comparing version 3.0.1 to 4.0.0
@@ -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" | ||
} | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
7748
42
+ Addedansi-colors@1.1.0(transitive)
+ Addedarr-diff@4.0.0(transitive)
+ Addedarr-union@3.1.0(transitive)
+ Addedassign-symbols@1.0.0(transitive)
+ Addedcss-tree@1.1.3(transitive)
+ Addedcsso@4.2.0(transitive)
+ Addedextend-shallow@3.0.2(transitive)
+ Addedis-extendable@1.0.1(transitive)
+ Addedis-plain-object@2.0.4(transitive)
+ Addedisobject@3.0.1(transitive)
+ Addedmdn-data@2.0.14(transitive)
+ Addedplugin-error@1.0.1(transitive)
+ Addedsource-map@0.6.1(transitive)
- Removedansi-cyan@0.1.1(transitive)
- Removedansi-red@0.1.1(transitive)
- Removedarr-diff@1.1.0(transitive)
- Removedarr-flatten@1.1.0(transitive)
- Removedarr-union@2.1.0(transitive)
- Removedarray-slice@0.2.3(transitive)
- Removedcss-tree@1.0.0-alpha.29(transitive)
- Removedcsso@3.5.1(transitive)
- Removedextend-shallow@1.1.4(transitive)
- Removedkind-of@1.1.0(transitive)
- Removedmdn-data@1.1.4(transitive)
- Removedplugin-error@0.1.2(transitive)
Updatedcsso@^4.0.0
Updatedplugin-error@^1.0.0