From ad5a0065ab82769d88e463499acf31b2702efa5c Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sun, 19 Feb 2017 10:44:39 +0200 Subject: [PATCH 1/3] Normalize package.json. Bump engines to node.js 0.10 which is what clean-css is using. --- package.json | 65 ++++++++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 37 deletions(-) diff --git a/package.json b/package.json index c18a55b..92fb379 100644 --- a/package.json +++ b/package.json @@ -1,39 +1,30 @@ { - "name": "less-plugin-clean-css", - "version": "1.5.1", - "description": "clean-css plugin for less.js", - "homepage": "http://lesscss.org", - "author": { - "name": "Luke Page" - }, - "contributors": [ - "The Core Less Team" - ], - "bugs": { - "url": "https://github.com/less/less-plugin-clean-css/issues" - }, - "repository": { - "type": "git", - "url": "https://github.com/less/less-plugin-clean-css.git" - }, - "licenses": [ - { - "type": "Apache v2", - "url": "https://github.com/less/less-plugin-clean-css/blob/master/LICENSE" - } - ], - "main": "lib/index.js", - "engines": { - "node": ">=0.4.2" - }, - "dependencies": { - "clean-css": "^3.0.1" - }, - "devDependencies": { - }, - "keywords": [ - "less plugins", - "cleancss", - "less compression" - ] + "name": "less-plugin-clean-css", + "version": "1.5.1", + "description": "clean-css plugin for less.js", + "homepage": "http://lesscss.org", + "author": "Luke Page", + "contributors": [ + "The Core Less Team" + ], + "bugs": { + "url": "https://github.com/less/less-plugin-clean-css/issues" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/less/less-plugin-clean-css.git" + }, + "license": "Apache-2.0", + "main": "lib/index.js", + "engines": { + "node": ">=0.10" + }, + "dependencies": { + "clean-css": "^3.0.1" + }, + "keywords": [ + "less plugins", + "cleancss", + "less compression" + ] } From 85424c4d20b5869d701f2f36ef8461355b087c6c Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sun, 19 Feb 2017 10:44:50 +0200 Subject: [PATCH 2/3] Lint tweaks. --- lib/clean-css-processor.js | 18 +++++++++--------- lib/index.js | 4 +++- lib/parse-options.js | 12 ++++++++---- lib/usage.js | 4 +++- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/lib/clean-css-processor.js b/lib/clean-css-processor.js index 9bd9a55..01010a3 100644 --- a/lib/clean-css-processor.js +++ b/lib/clean-css-processor.js @@ -1,10 +1,11 @@ -var CleanCSS = require('clean-css'), - usage = require("./usage"); +"use strict"; -module.exports = function(less) { +var CleanCSS = require("clean-css"); + +module.exports = function() { function CleanCSSProcessor(options) { this.options = options || {}; - }; + } CleanCSSProcessor.prototype = { process: function (css, extra) { @@ -24,16 +25,16 @@ module.exports = function(less) { } } - if (options.keepSpecialComments === undefined) { + if (typeof options.keepSpecialComments === "undefined") { options.keepSpecialComments = "*"; } options.processImport = false; - if (options.rebase === undefined) { + if (typeof options.rebase === "undefined") { options.rebase = false; } - if (options.advanced === undefined) { + if (typeof options.advanced === "undefined") { options.advanced = false; } @@ -41,8 +42,7 @@ module.exports = function(less) { if (sourceMap) { if (sourcesContent) { - for(var source = 0; source < sources.length; source++) - { + for (var source = 0; source < sources.length; source++) { output.sourceMap.setSourceContent(sources[source], sourcesContent[source]); } } diff --git a/lib/index.js b/lib/index.js index 1171411..4e65827 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,10 +1,12 @@ +"use strict"; + var getCleanCSSProcessor = require("./clean-css-processor"), usage = require("./usage"), parseOptions = require("./parse-options"); function LessPluginCleanCSS(options) { this.options = options; -}; +} LessPluginCleanCSS.prototype = { install: function(less, pluginManager) { diff --git a/lib/parse-options.js b/lib/parse-options.js index febe79c..a8e679e 100644 --- a/lib/parse-options.js +++ b/lib/parse-options.js @@ -1,11 +1,15 @@ +"use strict"; + module.exports = function(options) { - if (typeof options === 'string') { + if (typeof options === "string") { var cleanOptionArgs = options.split(" "); options = {}; - for(var i = 0; i < cleanOptionArgs.length; i++) { + + for (var i = 0; i < cleanOptionArgs.length; i++) { var argSplit = cleanOptionArgs[i].split("="), - argName = argSplit[0].replace(/^-+/,""); - switch(argName) { + argName = argSplit[0].replace(/^-+/, ""); + + switch (argName) { case "keep-line-breaks": case "b": options.keepBreaks = true; diff --git a/lib/usage.js b/lib/usage.js index 1df0ab4..e8b3054 100644 --- a/lib/usage.js +++ b/lib/usage.js @@ -1,3 +1,5 @@ +"use strict"; + module.exports = { printUsage: function() { console.log(""); @@ -14,6 +16,6 @@ module.exports = { printOptions: function() { console.log("we support the following arguments... 'keep-line-breaks', 'b'"); console.log("'s0', 's1', 'advanced', 'rebase', 'keepSpecialComments', compatibility', 'rounding-precision'"); - console.log("'skip-aggressive-merging', 'skip-shorthand-compacting'") + console.log("'skip-aggressive-merging', 'skip-shorthand-compacting'"); } }; From d6a6c080faf2f5c9637a37fef91be7248c1631ef Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sun, 19 Feb 2017 10:45:09 +0200 Subject: [PATCH 3/3] Clean up README.md. --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9acd084..e55655d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ -[![NPM version](https://badge.fury.io/js/less-plugin-clean-css.svg)](http://badge.fury.io/js/less-plugin-clean-css) [![Dependencies](https://david-dm.org/less/less-plugin-clean-css.svg)](https://david-dm.org/less/less-plugin-clean-css) [![devDependency Status](https://david-dm.org/less/less-plugin-clean-css/dev-status.svg)](https://david-dm.org/less/less-plugin-clean-css#info=devDependencies) [![optionalDependency Status](https://david-dm.org/less/less-plugin-clean-css/optional-status.svg)](https://david-dm.org/less/less-plugin-clean-css#info=optionalDependencies) +[![NPM version](https://badge.fury.io/js/less-plugin-clean-css.svg)](http://badge.fury.io/js/less-plugin-clean-css) [![Dependencies](https://david-dm.org/less/less-plugin-clean-css.svg)](https://david-dm.org/less/less-plugin-clean-css) -less-plugin-clean-css -===================== +# less-plugin-clean-css Compresses the css output from less using clean-css. @@ -21,7 +20,7 @@ See [clean-css](https://github.com/jakubpawlowicz/clean-css) for the available c ## Programmatic usage -``` +```js var LessPluginCleanCSS = require('less-plugin-clean-css'), cleanCSSPlugin = new LessPluginCleanCSS({advanced: true}); less.render(lessString, { plugins: [cleanCSSPlugin] })