From a9516af2af87953154e81b6080214798a9b64da5 Mon Sep 17 00:00:00 2001 From: Maksim Ryzhikov Date: Sat, 4 Oct 2014 07:43:56 +0400 Subject: [PATCH] fix(reporter): sourcemap not working in windows resolve #1200 --- lib/reporter.js | 2 +- test/unit/reporter.spec.coffee | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/reporter.js b/lib/reporter.js index c1119bac0..d7881b710 100644 --- a/lib/reporter.js +++ b/lib/reporter.js @@ -24,7 +24,7 @@ var createErrorFormatter = function(basePath, emitter, SourceMapConsumer) { var URL_REGEXP = new RegExp('http:\\/\\/[^\\/]*\\/' + '(base|absolute)' + // prefix - '([^\\?\\s\\:]*)' + // path + '((?:[A-z]\\:)?[^\\?\\s\\:]*)' + // path '(\\?\\w*)?' + // sha '(\\:(\\d+))?' + // line '(\\:(\\d+))?' + // column diff --git a/test/unit/reporter.spec.coffee b/test/unit/reporter.spec.coffee index 9001f9b00..0cb587e86 100644 --- a/test/unit/reporter.spec.coffee +++ b/test/unit/reporter.spec.coffee @@ -94,3 +94,28 @@ describe 'reporter', -> ERROR = 'at http://localhost:123/base/b.js:2:6' expect(formatError ERROR).to.equal 'at /some/base/b.js:2:6 <- /original/b.js:4:8\n' done() + + describe 'Windows', -> + formatError = null + servedFiles = null + + beforeEach -> + formatError = m.createErrorFormatter '/some/base', emitter, MockSourceMapConsumer + servedFiles = [new File('C:/a/b/c.js')] + servedFiles[0].sourceMap = 'SOURCE MAP b.js' + + it 'should correct rewrite stack traces without sha', (done) -> + emitter.emit 'file_list_modified', q(served: servedFiles) + + scheduleNextTick -> + ERROR = 'at http://localhost:123/absoluteC:/a/b/c.js:2:6' + expect(formatError ERROR).to.equal 'at C:/a/b/c.js:2:6 <- /original/b.js:4:8\n' + done() + + it 'should correct rewrite stack traces with sha', (done) -> + emitter.emit 'file_list_modified', q(served: servedFiles) + + scheduleNextTick -> + ERROR = 'at http://localhost:123/absoluteC:/a/b/c.js?da39a3ee5e6:2:6' + expect(formatError ERROR).to.equal 'at C:/a/b/c.js:2:6 <- /original/b.js:4:8\n' + done()