mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
move out clean css
This commit is contained in:
67
bin/lessc
67
bin/lessc
@@ -12,7 +12,6 @@ var args = process.argv.slice(1);
|
||||
var options = {
|
||||
depends: false,
|
||||
compress: false,
|
||||
cleancss: false,
|
||||
max_line_len: -1,
|
||||
silent: false,
|
||||
verbose: false,
|
||||
@@ -30,7 +29,6 @@ var options = {
|
||||
modifyVariables: '',
|
||||
urlArgs: ''
|
||||
};
|
||||
var cleancssOptions = {};
|
||||
var continueProcessing = true,
|
||||
currentErrorcode;
|
||||
|
||||
@@ -114,12 +112,6 @@ args = args.filter(function (arg) {
|
||||
case 'depends':
|
||||
options.depends = true;
|
||||
break;
|
||||
case 'yui-compress':
|
||||
warningMessages += "yui-compress option has been removed. ignoring.";
|
||||
break;
|
||||
case 'clean-css':
|
||||
options.cleancss = true;
|
||||
break;
|
||||
case 'max-line-len':
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
options.maxLineLen = parseInt(match[2], 10);
|
||||
@@ -213,40 +205,6 @@ args = args.filter(function (arg) {
|
||||
options.modifyVariables += parseVariableOption(match[2]);
|
||||
}
|
||||
break;
|
||||
case "clean-option":
|
||||
var cleanOptionArgs = match[2].split(":");
|
||||
switch(cleanOptionArgs[0]) {
|
||||
case "--keep-line-breaks":
|
||||
case "-b":
|
||||
cleancssOptions.keepBreaks = true;
|
||||
break;
|
||||
case "--s0":
|
||||
cleancssOptions.keepSpecialComments = 0;
|
||||
break;
|
||||
case "--s1":
|
||||
cleancssOptions.keepSpecialComments = 1;
|
||||
break;
|
||||
case "--skip-advanced":
|
||||
cleancssOptions.noAdvanced = true;
|
||||
break;
|
||||
case "--advanced":
|
||||
cleancssOptions.noAdvanced = false;
|
||||
break;
|
||||
case "--compatibility":
|
||||
cleancssOptions.compatibility = cleanOptionArgs[1];
|
||||
break;
|
||||
case "--rounding-precision":
|
||||
cleancssOptions.roundingPrecision = Number(cleanOptionArgs[1]);
|
||||
break;
|
||||
default:
|
||||
console.log("unrecognised clean-css option '" + cleanOptionArgs[0] + "'");
|
||||
console.log("we support only arguments that make sense for less, '--keep-line-breaks', '-b'");
|
||||
console.log("'--s0', '--s1', '--advanced', '--skip-advanced', '--compatibility', '--rounding-precision'");
|
||||
continueProcessing = false;
|
||||
currentErrorcode = 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'url-args':
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
options.urlArgs = match[2];
|
||||
@@ -254,8 +212,9 @@ args = args.filter(function (arg) {
|
||||
break;
|
||||
default:
|
||||
if (!pluginManager.interpretCommandLineArgument(arg, match[2])) {
|
||||
// TODO more of an explanation
|
||||
require('../lib/less/lessc_helper').printUsage();
|
||||
console.log("Unable to interpret argument " + arg + " - if it is a plugin (less-plugin-" + arg + "), make sure that it is installed under at the same level as less");
|
||||
console.log();
|
||||
require('../lib/less-node/lessc-helper').printUsage();
|
||||
continueProcessing = false;
|
||||
currentErrorcode = 1;
|
||||
}
|
||||
@@ -292,11 +251,6 @@ if (options.sourceMap === true) {
|
||||
options.sourceMap = path.basename(options.sourceMapFullFilename);
|
||||
}
|
||||
|
||||
if (options.cleancss && options.sourceMap) {
|
||||
console.log("the cleancss option is not compatible with sourcemap support at the moment. See Issue #1656");
|
||||
return;
|
||||
}
|
||||
|
||||
if (! input) {
|
||||
console.log("lessc: no input files");
|
||||
console.log("");
|
||||
@@ -378,21 +332,6 @@ var parseLessFile = function (e, data) {
|
||||
less.render(data, options)
|
||||
.then(function(css) {
|
||||
if(!options.lint) {
|
||||
if (options.cleancss) {
|
||||
var CleanCSS = require('clean-css');
|
||||
var cleancssOptions = options.cleancssOptions || {};
|
||||
|
||||
if (cleancssOptions.keepSpecialComments === undefined) {
|
||||
cleancssOptions.keepSpecialComments = "*";
|
||||
}
|
||||
cleancssOptions.processImport = false;
|
||||
cleancssOptions.noRebase = true;
|
||||
if (cleancssOptions.noAdvanced === undefined) {
|
||||
cleancssOptions.noAdvanced = true;
|
||||
}
|
||||
|
||||
css = new CleanCSS(cleancssOptions).minify(css);
|
||||
}
|
||||
if (output) {
|
||||
ensureDirectory(output);
|
||||
fs.writeFileSync(output, css, 'utf8');
|
||||
|
||||
@@ -9,7 +9,7 @@ NodePluginManager.prototype = new PluginManager();
|
||||
NodePluginManager.prototype.interpretCommandLineArgument = function(name, argument) {
|
||||
var plugin = this.tryRequirePlugin(name);
|
||||
if (plugin) {
|
||||
this.addPlugin(plugin);
|
||||
this.addPlugin(plugin, argument);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -21,7 +21,7 @@ NodePluginManager.prototype.tryRequirePlugin = function(name) {
|
||||
catch(e) {
|
||||
}
|
||||
try {
|
||||
return require("../../../less-plugin-"+name);
|
||||
return require("../../../less-plugin-" + name);
|
||||
}
|
||||
catch(e) {
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ ParseTree.prototype.toCSS = function(options) {
|
||||
for(var i = 0; i < postProcessors.length; i++) {
|
||||
// TODO - pass source maps
|
||||
// TODO - async
|
||||
css = postProcessors.process(css);
|
||||
css = postProcessors[i].process(css);
|
||||
}
|
||||
}
|
||||
return css;
|
||||
|
||||
@@ -6,8 +6,8 @@ var PluginManager = function(less) {
|
||||
this.visitors = [];
|
||||
this.postProcessors = [];
|
||||
};
|
||||
PluginManager.prototype.addPlugin = function(plugin) {
|
||||
plugin.install(this.less, this);
|
||||
PluginManager.prototype.addPlugin = function(plugin, options) {
|
||||
plugin.install(this.less, this, options);
|
||||
};
|
||||
PluginManager.prototype.addVisitor = function(visitor) {
|
||||
this.visitors.push(visitor);
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
"mime": "~1.2.11",
|
||||
"request": "~2.40.0",
|
||||
"mkdirp": "~0.5.0",
|
||||
"clean-css": "2.2.x",
|
||||
"source-map": "0.1.x",
|
||||
"promise": "~5.0.0"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user