Skip to content

Commit c952bcd

Browse files
tschaubjoshwiens
authored andcommitted
fix: work with sourcemaps when mocha is wrapped (#237) (#238)
* Work with source maps * Avoid calling callback twice
1 parent 33d8eaa commit c952bcd

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"async": "~0.9.0",
3838
"loader-utils": "^0.2.5",
3939
"lodash": "^3.8.0",
40-
"source-map": "^0.1.41",
40+
"source-map": "^0.5.6",
4141
"webpack-dev-middleware": "^1.12.0"
4242
},
4343
"devDependencies": {

src/mocha-env-loader.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
//var path = require('path')
2-
var SourceNode = require('source-map').SourceNode
1+
var sourceMap = require('source-map')
32
var loaderUtils = require('loader-utils')
43

4+
var SourceNode = sourceMap.SourceNode
5+
var SourceMapConsumer = sourceMap.SourceMapConsumer
6+
57
module.exports = function(content, map) {
68
this.cacheable()
79

810
var sourceNode
911
var id = this.options.name
1012

1113
if (!id) {
12-
this.callback(null, content, map)
14+
return this.callback(null, content, map)
1315
}
1416

1517
if (map) {
16-
sourceNode = SourceNode.fromSourceWithMap(content, map)
18+
sourceNode = SourceNode.fromStringWithSourceMap(content, new SourceMapConsumer(map))
1719
} else {
1820
var fileName = loaderUtils.getRemainingRequest(this)
1921

0 commit comments

Comments
 (0)