From afbe22d2157b6ab0c967770cf2ded5ce21cd49b4 Mon Sep 17 00:00:00 2001 From: Stefan Wallin Date: Wed, 4 Jan 2012 12:11:00 +0100 Subject: [PATCH] * "Added a -depends switch which outputs a dependency line suitable for a makefile" (10696d9c11afccd7fb4dadd92985b5166c66f6f2) * Added a synonym flag "-M" to "-depends" to match syntax of other compilers. * Added support for recursive dependencies. * Fixed some issues with path calculation when dependencies and recursive dependencies. lukeapage - removed the actual writing of dependency lines ready for re-implementation --- bin/lessc | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/bin/lessc b/bin/lessc index 32906561..aec3d837 100755 --- a/bin/lessc +++ b/bin/lessc @@ -9,6 +9,7 @@ var path = require('path'), var less = require('../lib/less'); var args = process.argv.slice(1); var options = { + depends: false, compress: false, yuicompress: false, optimization: 1, @@ -68,6 +69,10 @@ args = args.filter(function (arg) { case 'compress': options.compress = true; break; + case 'M': + case 'depends': + options.depends = true; + break; case 'yui-compress': options.yuicompress = true; break; @@ -125,10 +130,12 @@ if (!continueProcessing) { } var input = args[1]; +var inputbase = args[1]; if (input && input != '-') { input = path.resolve(process.cwd(), input); } var output = args[2]; +var outputbase = args[2]; if (output) { output = path.resolve(process.cwd(), output); } @@ -155,6 +162,11 @@ var ensureDirectory = function (filepath) { } }; +if (options.depends) { + // output the target filename, needs to be specified on the command line (no stdout) + sys.print(outputbase + ": "); +} + var parseLessFile = function (e, data) { if (e) { sys.puts("lessc: " + e.message); @@ -165,12 +177,15 @@ var parseLessFile = function (e, data) { options.paths = [path.dirname(input)].concat(options.paths); options.filename = input; - new(less.Parser)(options) - .parse(data, function (err, tree) { + var parser = new(less.Parser)(options); + parser.parse(data, function (err, tree) { if (err) { less.writeError(err, options); currentErrorcode = 1; return; + } else if (options.depends) { + // todo - loop through the imports + // sys.print(path.resolve(path.dirname(env.parentPath),importname) } else if(!options.lint) { try { var css = tree.toCSS({