Skip to content

Commit

Permalink
Make Error.prepareStackTrace read-only (again)
Browse files Browse the repository at this point in the history
This time, we've provided a way for Grim to access an Error's
raw stack trace array
  • Loading branch information
maxbrunsfeld committed Oct 16, 2015
1 parent 7d74382 commit c36b4bd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"fstream": "0.1.24",
"fuzzaldrin": "^2.1",
"git-utils": "^4",
"grim": "1.4.2",
"grim": "1.5.0",
"jasmine-json": "~0.0",
"jasmine-tagged": "^1.1.4",
"jquery": "^2.1.1",
Expand Down
21 changes: 21 additions & 0 deletions src/compile-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,27 @@ require('source-map-support').install({
}
})

var sourceMapPrepareStackTrace = Error.prepareStackTrace
var prepareStackTrace = sourceMapPrepareStackTrace

// Prevent coffee-script from reassigning Error.prepareStackTrace
Object.defineProperty(Error, 'prepareStackTrace', {
get: function () { return prepareStackTrace },
set: function (newValue) {}
})

// Enable Grim to access the raw stack without reassigning Error.prepareStackTrace
Error.prototype.getRawStack = function () {
prepareStackTrace = getRawStack
var result = this.stack
prepareStackTrace = sourceMapPrepareStackTrace
return result
}

function getRawStack (error, stack) {
return stack
}

Object.keys(COMPILERS).forEach(function (extension) {
var compiler = COMPILERS[extension]

Expand Down

0 comments on commit c36b4bd

Please sign in to comment.