mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
Fix source maps for errors thrown from .coffee.md files
Before:
```
$ cat tmp.coffee.md
test
a
$ ./bin/coffee tmp.coffee.md
ReferenceError: a is not defined
at Object.<anonymous> (/src/coffee-script/tmp.coffee.md:2:3)
...
```
Note how the line and column numbers (2 and 3, respectively) are not
correct.
After:
```
$ ./bin/coffee tmp.coffee.md
ReferenceError: a is not defined
at Object.<anonymous> (/home/lydell/forks/coffee-script/tmp.coffee.md:3:5)
...
```
Line 3, column 5 is the actual position of the `a` in tmp.coffee.md.
Supersedes and fixes #4204.
This commit is contained in:
@@ -334,9 +334,11 @@ sourceMaps = {}
|
||||
# Generates the source map for a coffee file and stores it in the local cache variable.
|
||||
getSourceMap = (filename) ->
|
||||
return sourceMaps[filename] if sourceMaps[filename]
|
||||
return unless path?.extname(filename) in exports.FILE_EXTENSIONS
|
||||
answer = exports._compileFile filename, true
|
||||
sourceMaps[filename] = answer.sourceMap
|
||||
for ext in exports.FILE_EXTENSIONS
|
||||
if helpers.ends filename, ext
|
||||
answer = exports._compileFile filename, true
|
||||
return sourceMaps[filename] = answer.sourceMap
|
||||
return null
|
||||
|
||||
# Based on [michaelficarra/CoffeeScriptRedux](http://goo.gl/ZTx1p)
|
||||
# NodeJS / V8 have no support for transforming positions in stack traces using
|
||||
|
||||
Reference in New Issue
Block a user