From 772726ca96a67af0b8688cd6ffd62bd2d9e36c69 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 23 Jul 2014 16:49:53 -0700 Subject: [PATCH] Fix source maps for CoffeeScript on Windows. The sourceURL needs to be a URL, not a file path. --- src/coffee-cache.coffee | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/coffee-cache.coffee b/src/coffee-cache.coffee index 0da37b1bd..47ef7245d 100644 --- a/src/coffee-cache.coffee +++ b/src/coffee-cache.coffee @@ -18,11 +18,17 @@ getCachedJavaScript = (cachePath) -> try fs.readFileSync(cachePath, 'utf8') +convertFilePath = (filePath) -> + if process.platform is 'win32' + encodeURI '/' + path.resolve(filePath).replace(/\\/g, '/') + else + encodeURI filePath + compileCoffeeScript = (coffee, filePath, cachePath) -> {js, v3SourceMap} = CoffeeScript.compile(coffee, filename: filePath, sourceMap: true) # Include source map in the web page environment. if btoa? and JSON? and unescape? and encodeURIComponent? - js = "#{js}\n//# sourceMappingURL=data:application/json;base64,#{btoa unescape encodeURIComponent v3SourceMap}\n//# sourceURL=#{filePath}" + js = "#{js}\n//# sourceMappingURL=data:application/json;base64,#{btoa unescape encodeURIComponent v3SourceMap}\n//# sourceURL=#{convertFilePath(filePath)}" try fs.writeFileSync(cachePath, js) js