Skip to content

Commit afbe22d

Browse files
StefanWallinlukeapage
authored andcommitted
* "Added a -depends switch which outputs a dependency line suitable for a makefile" (10696d9)
* 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
1 parent dca1650 commit afbe22d

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

bin/lessc

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ var path = require('path'),
99
var less = require('../lib/less');
1010
var args = process.argv.slice(1);
1111
var options = {
12+
depends: false,
1213
compress: false,
1314
yuicompress: false,
1415
optimization: 1,
@@ -68,6 +69,10 @@ args = args.filter(function (arg) {
6869
case 'compress':
6970
options.compress = true;
7071
break;
72+
case 'M':
73+
case 'depends':
74+
options.depends = true;
75+
break;
7176
case 'yui-compress':
7277
options.yuicompress = true;
7378
break;
@@ -125,10 +130,12 @@ if (!continueProcessing) {
125130
}
126131

127132
var input = args[1];
133+
var inputbase = args[1];
128134
if (input && input != '-') {
129135
input = path.resolve(process.cwd(), input);
130136
}
131137
var output = args[2];
138+
var outputbase = args[2];
132139
if (output) {
133140
output = path.resolve(process.cwd(), output);
134141
}
@@ -155,6 +162,11 @@ var ensureDirectory = function (filepath) {
155162
}
156163
};
157164

165+
if (options.depends) {
166+
// output the target filename, needs to be specified on the command line (no stdout)
167+
sys.print(outputbase + ": ");
168+
}
169+
158170
var parseLessFile = function (e, data) {
159171
if (e) {
160172
sys.puts("lessc: " + e.message);
@@ -165,12 +177,15 @@ var parseLessFile = function (e, data) {
165177
options.paths = [path.dirname(input)].concat(options.paths);
166178
options.filename = input;
167179

168-
new(less.Parser)(options)
169-
.parse(data, function (err, tree) {
180+
var parser = new(less.Parser)(options);
181+
parser.parse(data, function (err, tree) {
170182
if (err) {
171183
less.writeError(err, options);
172184
currentErrorcode = 1;
173185
return;
186+
} else if (options.depends) {
187+
// todo - loop through the imports
188+
// sys.print(path.resolve(path.dirname(env.parentPath),importname)
174189
} else if(!options.lint) {
175190
try {
176191
var css = tree.toCSS({

0 commit comments

Comments
 (0)