Allowing parse of non-JSON manifest stylesheets in messc

This commit is contained in:
Tom MacWright 2011-01-13 14:24:03 -05:00
parent 8ed2b5febd
commit cdde96a0ff

View File

@ -12,7 +12,7 @@ var options = {
compress: false, compress: false,
optimization: 1, optimization: 1,
silent: false, silent: false,
json: true json: false
}; };
args = args.filter(function (arg) { args = args.filter(function (arg) {
@ -71,16 +71,37 @@ fs.readFile(input, 'utf-8', function (e, data) {
process.exit(1); process.exit(1);
} }
new(mess.Renderer)({ if (options.json) {
paths: [path.dirname(input)], new(mess.Renderer)({
optimization: options.optimization, paths: [path.dirname(input)],
filename: input optimization: options.optimization,
}).render(data, function (err, output) { filename: input
if (err) { }).render(data, function (err, output) {
mess.writeError(err, options); if (err) {
process.exit(1); mess.writeError(err, options);
} else { process.exit(1);
sys.puts(output); } else {
} sys.puts(output);
}); }
});
} else {
new(mess.Parser)({
paths: [path.dirname(input)],
optimization: options.optimization,
filename: input
}).parse(data, function (err, tree) {
if (err) {
less.writeError(err, options);
process.exit(1);
} else {
try {
css = tree.toCSS({ compress: options.compress });
sys.print(css);
} catch (e) {
less.writeError(e, options);
process.exit(2);
}
}
});
}
}); });