html-minifier
Advanced tools
Comparing version 1.0.0 to 1.0.1
79
cli.js
@@ -94,3 +94,5 @@ #!/usr/bin/env node | ||
output: ['o', 'Specify output file (if not specified STDOUT will be used for output)', 'file'], | ||
'config-file': ['c', 'Use config file', 'file'] | ||
'config-file': ['c', 'Use config file', 'file'], | ||
'input-dir': [false, 'Specify an input directory', 'dir'], | ||
'output-dir': [false, 'Specify an output directory', 'dir'] | ||
}; | ||
@@ -158,3 +160,3 @@ | ||
function runMinify(original) { | ||
function runMinify(original, output) { | ||
var status = 0; | ||
@@ -187,9 +189,40 @@ var minified = null; | ||
status = 4; | ||
console.log(output); | ||
cli.error('Cannot write to output'); | ||
} | ||
} | ||
} | ||
cli.exit(status); | ||
function createDirectory(path) { | ||
try { | ||
fs.mkdirSync(path); | ||
} | ||
catch (e) { | ||
if (e.code === 'EEXIST') { | ||
return; | ||
} | ||
cli.fatal('Can not create directory ' + path); | ||
cli.exit(3); | ||
} | ||
} | ||
function processDirectory(inputDir, outputDir) { | ||
createDirectory(outputDir); | ||
var fileList = fs.readdirSync(inputDir); | ||
fileList.forEach(function(fileName) { | ||
var inputFilePath = inputDir + '/' + fileName; | ||
var outputFilePath = outputDir + '/' + fileName; | ||
var stat = fs.statSync(inputFilePath); | ||
if (stat.isDirectory()) { | ||
processDirectory(inputFilePath, outputFilePath); | ||
return; | ||
} | ||
var originalContent = fs.readFileSync(inputFilePath, 'utf8'); | ||
runMinify(originalContent, outputFilePath); | ||
}); | ||
} | ||
if (options.version) { | ||
@@ -256,2 +289,38 @@ cli.output(appName + ' v' + appVersion); | ||
if (options['input-dir'] || options['output-dir']) { | ||
var inputDir = options['input-dir']; | ||
var outputDir = options['output-dir']; | ||
if (!inputDir) { | ||
cli.error('The option output-dir need to be use with the option include-dir. If you are working with only 1 file, use -o.'); | ||
cli.exit(2); | ||
} | ||
try { | ||
fs.statSync(inputDir); | ||
} | ||
catch (e) { | ||
cli.error('The input directory does not exits'); | ||
cli.exit(2); | ||
} | ||
if (!outputDir) { | ||
cli.error('You need to specify where to write the output files with the option --output-dir'); | ||
cli.exit(2); | ||
} | ||
try { | ||
processDirectory(inputDir, outputDir); | ||
} | ||
catch (e) { | ||
cli.error('Something wrong happened'); | ||
cli.error(e); | ||
cli.exit(3); | ||
} | ||
cli.exit(0); | ||
return; | ||
} | ||
if (options.output) { | ||
@@ -275,3 +344,3 @@ output = options.output; | ||
runMinify(original); | ||
runMinify(original, output); | ||
@@ -282,3 +351,3 @@ } | ||
} | ||
cli.exit(status); | ||
}); |
/*! | ||
* HTMLMinifier v1.0.0 (http://kangax.github.io/html-minifier/) | ||
* HTMLMinifier v1.0.1 (http://kangax.github.io/html-minifier/) | ||
* Copyright 2010-2015 Juriy "kangax" Zaytsev | ||
@@ -4,0 +4,0 @@ * Licensed under the MIT license |
/*! | ||
* HTMLMinifier v1.0.0 (http://kangax.github.io/html-minifier/) | ||
* HTMLMinifier v1.0.1 (http://kangax.github.io/html-minifier/) | ||
* Copyright 2010-2015 Juriy "kangax" Zaytsev | ||
@@ -4,0 +4,0 @@ * Licensed under the MIT license |
{ | ||
"name": "html-minifier", | ||
"description": "HTML minifier with lint-like capabilities.", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"keywords": [ | ||
@@ -44,3 +44,3 @@ "html", | ||
"relateurl": "0.2.x", | ||
"uglify-js": "2.5.x" | ||
"uglify-js": "2.6.x" | ||
}, | ||
@@ -54,8 +54,8 @@ "devDependencies": { | ||
"grunt-contrib-qunit": "0.7.x", | ||
"grunt-contrib-uglify": "0.9.x", | ||
"grunt-contrib-uglify": "0.11.x", | ||
"grunt-exec": "0.4.x", | ||
"grunt-jscs": "2.1.x", | ||
"load-grunt-tasks": "3.3.x", | ||
"grunt-jscs": "2.5.x", | ||
"load-grunt-tasks": "3.4.x", | ||
"qunit": "0.7.x", | ||
"time-grunt": "1.2.x" | ||
"time-grunt": "1.3.x" | ||
}, | ||
@@ -62,0 +62,0 @@ "files": [ |
@@ -49,3 +49,2 @@ [![NPM version](https://img.shields.io/npm/v/html-minifier.svg)](https://www.npmjs.com/package/html-minifier) | ||
| `removeOptionalTags` | [Remove unrequired tags](http://perfectionkills.com/experimenting-with-html-minifier/#remove_optional_tags) | `false` | | ||
| `removeIgnored` | Remove all tags starting and ending with `<%`, `%>`, `<?`, `?>` | `false` | | ||
| `removeEmptyElements` | [Remove all elements with empty contents](http://perfectionkills.com/experimenting-with-html-minifier/#remove_empty_elements) | `false` | | ||
@@ -59,2 +58,3 @@ | `lint` | [Toggle linting](http://perfectionkills.com/experimenting-with-html-minifier/#validate_input_through_html_lint) | `false` | | ||
| `ignoreCustomComments` | Array of regex'es that allow to ignore certain comments, when matched | `[ ]` | | ||
| `ignoreCustomFragments` | Array of regex'es that allow to ignore certain fragments, when matched (e.g. `<?php ... ?>`, `{{ ... }}`, etc.) | `[ ]` | | ||
| `processScripts` | Array of strings corresponding to types of script elements to process through minifier (e.g. `text/ng-template`, `text/x-handlebars-template`, etc.) | `[ ]` | | ||
@@ -61,0 +61,0 @@ | `maxLineLength` | Specify a maximum line length. Compressed output will be split by newlines at valid HTML split-points. | |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
146768
3014
+ Addedalign-text@0.1.4(transitive)
+ Addedcenter-align@0.1.3(transitive)
+ Addedcliui@2.1.0(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedkind-of@3.2.2(transitive)
+ Addedlazy-cache@1.0.4(transitive)
+ Addedlongest@1.0.1(transitive)
+ Addedrepeat-string@1.6.1(transitive)
+ Addedright-align@0.1.3(transitive)
+ Addeduglify-js@2.6.4(transitive)
+ Addedyargs@3.10.0(transitive)
- Removeduglify-js@2.5.0(transitive)
- Removedyargs@3.5.4(transitive)
Updateduglify-js@2.6.x