forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes angular#5444
- Loading branch information
Showing
10 changed files
with
234 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12153,6 +12153,9 @@ | |
} | ||
} | ||
}, | ||
"karma-sourcemap-loader": { | ||
"version": "0.3.6" | ||
}, | ||
"lodash": { | ||
"version": "2.4.2" | ||
}, | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
var SourceMapConsumer = require('source-map').SourceMapConsumer; | ||
var DotsReporter = require('karma/lib/reporters/dots_color'); | ||
|
||
var createErrorFormatter = function (basePath, emitter, SourceMapConsumer) { | ||
var lastServedFiles = []; | ||
emitter.on('file_list_modified', function (files) { | ||
lastServedFiles = files.served | ||
}); | ||
function findFile(path) { | ||
return lastServedFiles.filter(_ => _.path === path)[0]; | ||
} | ||
|
||
var URL_REGEXP = new RegExp('(?:https?:\\/\\/[^\\/]*)?\\/?' + | ||
'(base|absolute)' + // prefix | ||
'((?:[A-z]\\:)?[^\\?\\s\\:]*)' + // path | ||
'(\\?\\w*)?' + // sha | ||
'(\\:(\\d+))?' + // line | ||
'(\\:(\\d+))?' + // column | ||
'', 'g') | ||
|
||
return function (msg, indentation) { | ||
msg = (msg || '').replace(URL_REGEXP, function (_, prefix, path, __, ___, line, ____, column) { | ||
if (prefix === 'base') { | ||
path = basePath + path; | ||
} | ||
line = parseInt(line || '0', 10); | ||
column = parseInt(column || '0', 10); | ||
|
||
var file = findFile(path) | ||
if (file && file.sourceMap) { | ||
try { | ||
var original = new SourceMapConsumer(file.sourceMap).originalPositionFor({ | ||
line: line, | ||
column: column | ||
}); | ||
return process.cwd() + "/modules/" + original.source + ":" + original.line + ":" + original.column; | ||
} catch (e) { | ||
log.warn('SourceMap position not found for trace: %s', msg); | ||
} | ||
} | ||
return path + ':' + line + ':' + column; | ||
}); | ||
|
||
// indent every line | ||
if (indentation) { | ||
msg = indentation + msg.replace(/\n/g, '\n' + indentation) | ||
} | ||
return msg + '\n'; | ||
} | ||
} | ||
|
||
|
||
var InternalAngularReporter = function (config, emitter) { | ||
var formatter = createErrorFormatter(config.basePath, emitter, SourceMapConsumer); | ||
DotsReporter.call(this, formatter, false) | ||
} | ||
InternalAngularReporter.$inject = ['config', 'emitter'] | ||
|
||
module.exports = {'reporter:internal-angular': ['type', InternalAngularReporter]}; |