add highlightErrors option - fixes #837
This commit is contained in:
parent
866d3a8eab
commit
1fb877e9f5
@ -55,10 +55,10 @@ var highlight = function (text) {
|
||||
});
|
||||
};
|
||||
|
||||
export default function (lines, lineNumber, colNumber) {
|
||||
export default function (lines: number, lineNumber: number, colNumber: number, color?): string {
|
||||
colNumber = Math.max(colNumber, 0);
|
||||
|
||||
if (chalk.supportsColor) {
|
||||
if (color && chalk.supportsColor) {
|
||||
lines = highlight(lines);
|
||||
}
|
||||
|
||||
|
||||
@ -32,12 +32,12 @@ export default function (opts, code, callback) {
|
||||
} catch (err) {
|
||||
if (!err._babel) {
|
||||
err._babel = true;
|
||||
|
||||
var message = `${opts.filename}: ${err.message}`;
|
||||
|
||||
var loc = err.loc;
|
||||
if (loc) {
|
||||
var frame = codeFrame(code, loc.line, loc.column + 1);
|
||||
message += frame;
|
||||
message += codeFrame(code, loc.line, loc.column + 1, opts.highlightErrors);
|
||||
}
|
||||
|
||||
if (err.stack) {
|
||||
|
||||
@ -19,6 +19,12 @@
|
||||
|
||||
},
|
||||
|
||||
"highlightErrors": {
|
||||
"description": "ANSI syntax highlight error messages"
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
|
||||
"suppressDeprecationMessages": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user