Skip to content

Commit

Permalink
fix: work with sourcemaps when mocha is wrapped (#237) (#238)
Browse files Browse the repository at this point in the history
* Work with source maps

 * Avoid calling callback twice
  • Loading branch information
tschaub authored and joshwiens committed Nov 10, 2017
1 parent 33d8eaa commit c952bcd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"async": "~0.9.0",
"loader-utils": "^0.2.5",
"lodash": "^3.8.0",
"source-map": "^0.1.41",
"source-map": "^0.5.6",
"webpack-dev-middleware": "^1.12.0"
},
"devDependencies": {
Expand Down
10 changes: 6 additions & 4 deletions src/mocha-env-loader.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
//var path = require('path')
var SourceNode = require('source-map').SourceNode
var sourceMap = require('source-map')
var loaderUtils = require('loader-utils')

var SourceNode = sourceMap.SourceNode
var SourceMapConsumer = sourceMap.SourceMapConsumer

module.exports = function(content, map) {
this.cacheable()

var sourceNode
var id = this.options.name

if (!id) {
this.callback(null, content, map)
return this.callback(null, content, map)
}

if (map) {
sourceNode = SourceNode.fromSourceWithMap(content, map)
sourceNode = SourceNode.fromStringWithSourceMap(content, new SourceMapConsumer(map))
} else {
var fileName = loaderUtils.getRemainingRequest(this)

Expand Down

0 comments on commit c952bcd

Please sign in to comment.