Socket
Socket
Sign inDemoInstall

html-minifier

Package Overview
Dependencies
7
Maintainers
2
Versions
80
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.0 to 3.0.1

81

cli.js

@@ -110,3 +110,2 @@ #!/usr/bin/env node

decodeEntities: 'Use direct Unicode characters whenever possible',
html5: 'Parse input according to HTML5 specifications',

@@ -212,2 +211,40 @@ ignoreCustomComments: ['Array of regex\'es that allow to ignore certain comments, when matched', parseJSONRegExpArray],

function mkdir(outputDir, callback) {
fs.mkdir(outputDir, function(err) {
if (err) {
switch (err.code) {
case 'ENOENT':
return mkdir(path.join(outputDir, '..'), function() {
mkdir(outputDir, callback);
});
case 'EEXIST':
break;
default:
fatal('Cannot create directory ' + outputDir + '\n' + err.message);
}
}
callback();
});
}
function processFile(inputFile, outputFile) {
fs.readFile(inputFile, { encoding: 'utf8' }, function(err, data) {
if (err) {
fatal('Cannot read ' + inputFile + '\n' + err.message);
}
var minified;
try {
minified = minify(data, createOptions());
}
catch (e) {
fatal('Minification error on ' + inputFile + '\n' + e.message);
}
fs.writeFile(outputFile, minified, { encoding: 'utf8' }, function(err) {
if (err) {
fatal('Cannot write ' + outputFile + '\n' + err.message);
}
});
});
}
function processDirectory(inputDir, outputDir, fileExt) {

@@ -218,31 +255,15 @@ fs.readdir(inputDir, function(err, files) {

}
fs.mkdir(outputDir, function(err) {
if (err && err.code !== 'EEXIST') {
fatal('Cannot create directory ' + outputDir + '\n' + err.message);
}
files.forEach(function(file) {
var inputFile = path.join(inputDir, file);
var outputFile = path.join(outputDir, file);
if (fileExt ? path.extname(file) === '.' + fileExt : true) {
fs.readFile(inputFile, { encoding: 'utf8' }, function(err, data) {
if (!err) {
var minified;
try {
minified = minify(data, createOptions());
}
catch (e) {
fatal('Minification error on ' + inputFile + '\n' + e.message);
}
fs.writeFile(outputFile, minified, { encoding: 'utf8' }, function(err) {
if (err) {
fatal('Cannot write ' + outputFile + '\n' + err.message);
}
});
}
else if (err.code === 'EISDIR') {
processDirectory(inputFile, outputFile, fileExt);
}
else {
fatal('Cannot read ' + inputFile + '\n' + err.message);
}
files.forEach(function(file) {
var inputFile = path.join(inputDir, file);
var outputFile = path.join(outputDir, file);
fs.stat(inputFile, function(err, stat) {
if (err) {
fatal('Cannot read ' + inputFile + '\n' + err.message);
}
else if (stat.isDirectory()) {
processDirectory(inputFile, outputFile, fileExt);
}
else if (!fileExt || path.extname(file) === '.' + fileExt) {
mkdir(outputDir, function() {
processFile(inputFile, outputFile);
});

@@ -249,0 +270,0 @@ }

{
"name": "html-minifier",
"description": "Highly configurable, well-tested, JavaScript-based HTML minifier.",
"version": "3.0.0",
"version": "3.0.1",
"keywords": [

@@ -6,0 +6,0 @@ "cli",

@@ -26,11 +26,11 @@ # HTMLMinifier

| [Google](https://www.google.com/) | 44 | **43** | 45 | 46 | 45 |
| [CNN](http://www.cnn.com/) | 115 | **104** | 111 | 112 | 108 |
| [HTMLMinifier](https://github.com/kangax/html-minifier) | 118 | **80** | 100 | 105 | 101 |
| [BBC](http://www.bbc.co.uk/) | 180 | **147** | 173 | 178 | 169 |
| [New York Times](http://www.nytimes.com/) | 188 | **128** | 138 | 142 | 135 |
| [Stack Overflow](http://stackoverflow.com/) | 237 | **183** | 192 | 200 | 190 |
| [CNN](http://www.cnn.com/) | 116 | **106** | 112 | 113 | 110 |
| [HTMLMinifier](https://github.com/kangax/html-minifier) | 118 | **79** | 100 | 104 | 100 |
| [BBC](http://www.bbc.co.uk/) | 188 | **154** | 181 | 185 | 176 |
| [New York Times](http://www.nytimes.com/) | 191 | **129** | 140 | 144 | 136 |
| [Stack Overflow](http://stackoverflow.com/) | 238 | **184** | 192 | 201 | 191 |
| [Bootstrap CSS](http://getbootstrap.com/css/) | 277 | **264** | 274 | 232 | 274 |
| [Amazon](http://www.amazon.co.uk/) | 429 | **374** | 409 | 421 | n/a |
| [Amazon](http://www.amazon.co.uk/) | 452 | **397** | 432 | 445 | n/a |
| [Wikipedia](https://en.wikipedia.org/wiki/President_of_the_United_States) | 481 | **437** | 465 | 480 | n/a |
| [NBC](http://www.nbc.com/) | 499 | **477** | 497 | 499 | n/a |
| [NBC](http://www.nbc.com/) | 499 | **478** | 497 | 499 | n/a |
| [Eloquent Javascript](http://eloquentjavascript.net/1st_edition/print.html) | 870 | **815** | 840 | 864 | n/a |

@@ -37,0 +37,0 @@ | [ES6 table](http://kangax.github.io/compat-table/es6/) | 3884 | **3272** | 3665 | 3839 | n/a |

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc