From 7b4ebef2a4cf76374fb57033997704c6506c400f Mon Sep 17 00:00:00 2001 From: cloudhead Date: Fri, 11 Jun 2010 20:38:44 -0400 Subject: [PATCH] (bin) add compress and optimization options --- bin/lessc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/bin/lessc b/bin/lessc index ed10b6db..04d0a41b 100755 --- a/bin/lessc +++ b/bin/lessc @@ -8,6 +8,10 @@ require.paths.unshift(path.join(__dirname, '..', 'lib')); var less = require('less'); var args = process.argv.slice(1); +var options = { + compress: false, + optimization: 1 +}; args = args.filter(function (arg) { var match; @@ -24,6 +28,13 @@ args = args.filter(function (arg) { case 'help': sys.puts("usage: lessc source [destination]"); process.exit(0); + case 'x': + case 'compress': + options.compress = true; + break; + case 'O0': options.optimization = 0; break; + case 'O1': options.optimization = 1; break; + case 'O2': options.optimization = 2; break; } }); @@ -52,12 +63,13 @@ fs.stat(input, function (e, stats) { fs.read(fd, stats.size, 0, "utf8", function (e, data) { new(less.Parser)({ paths: [path.dirname(input)], + optimization: options.optimization, filename: input }).parse(data, function (err, tree) { if (err) { less.writeError(err); } else { - css = tree.toCSS(); + css = tree.toCSS({ compress: options.compress }); if (output) { fd = fs.openSync(output, "w"); fs.writeSync(fd, css, 0, "utf8");