Skip to content

Commit

Permalink
fix(reporter): Ensure errors use the source map.
Browse files Browse the repository at this point in the history
Closes #1495
  • Loading branch information
brianmhunt authored and dignifiedquire committed Aug 4, 2015
1 parent 4673116 commit 0407a22
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var createErrorFormatter = function (basePath, emitter, SourceMapConsumer) {
return null
}

var URL_REGEXP = new RegExp('http:\\/\\/[^\\/]*\\/' +
var URL_REGEXP = new RegExp('(?:http:\\/\\/[^\\/]*)?\\/?' +
'(base|absolute)' + // prefix
'((?:[A-z]\\:)?[^\\?\\s\\:]*)' + // path
'(\\?\\w*)?' + // sha
Expand Down
15 changes: 15 additions & 0 deletions test/unit/reporter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,21 @@ describe('reporter', () => {
}, 100))
})

it('should rewrite relative url stack traces', done => {
formatError = m.createErrorFormatter('/some/base', emitter, MockSourceMapConsumer)
var servedFiles = [new File('/some/base/a.js'), new File('/some/base/b.js')]
servedFiles[0].sourceMap = {content: 'SOURCE MAP a.js'}
servedFiles[1].sourceMap = {content: 'SOURCE MAP b.js'}

emitter.emit('file_list_modified', {served: servedFiles})

_.defer(() => _.delay(() => {
var ERROR = 'at /base/b.js:2:6'
expect(formatError(ERROR)).to.equal('at /some/base/b.js:2:6 <- /original/b.js:4:8\n')
done()
}, 100))
})

it('should fall back to non-source-map format if originalPositionFor throws', done => {
formatError = m.createErrorFormatter('/some/base', emitter, MockSourceMapConsumer)
var servedFiles = [new File('/some/base/a.js'), new File('/some/base/b.js')]
Expand Down

0 comments on commit 0407a22

Please sign in to comment.