Skip to content

Commit

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

 * Avoid calling callback twice
  • Loading branch information
tschaub committed May 4, 2017
1 parent 4701b62 commit 39c05da
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 @@ -38,7 +38,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.0.11"
},
"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 39c05da

Please sign in to comment.