silent option. pass options through writeError

This commit is contained in:
cloudhead 2010-06-18 19:51:29 -04:00
parent 187315fae8
commit f872b0f3f3
3 changed files with 14 additions and 6 deletions

View File

@ -10,7 +10,8 @@ var less = require('less');
var args = process.argv.slice(1);
var options = {
compress: false,
optimization: 1
optimization: 1,
silent: false
};
args = args.filter(function (arg) {
@ -27,6 +28,10 @@ args = args.filter(function (arg) {
case 'verbose':
options.verbose = true;
break;
case 's':
case 'silent':
options.silent = true;
break;
case 'h':
case 'help':
sys.puts("usage: lessc source [destination]");
@ -70,7 +75,7 @@ fs.stat(input, function (e, stats) {
filename: input
}).parse(data, function (err, tree) {
if (err) {
less.writeError(err);
less.writeError(err, options);
process.exit(1);
} else {
try {
@ -82,7 +87,7 @@ fs.stat(input, function (e, stats) {
sys.print(css);
}
} catch (e) {
less.writeError(e);
less.writeError(e, options);
process.exit(2);
}
}

View File

@ -35,11 +35,15 @@ var less = {
return ee;
}
},
writeError: function (ctx) {
writeError: function (ctx, options) {
var message = "";
var extract = ctx.extract;
var error = [];
options = options || {};
if (options.silent) { return }
if (!ctx.index && ctx.stack) {
return sys.error(ctx.stack);
}
@ -62,7 +66,7 @@ var less = {
sys.error(message, error);
if (ctx.verbose && ctx.stack) { sys.error(stylize(ctx.stack, 'red')) }
if (options.verbose && ctx.stack) { sys.error(stylize(ctx.stack, 'red')) }
}
};

View File

@ -242,7 +242,6 @@ less.Parser = function Parser(env) {
line: line,
stack: e.stack,
column: column,
verbose: env.verbose,
extract: [
lines[line - 2],
lines[line - 1],