Skip to content

Commit b18525e

Browse files
committed
Merge pull request #85 from taylorzane/feature/coffeescript
Resolved issue with CoffeeScript failing to build
2 parents 9a47a3f + de92982 commit b18525e

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

lib/parser.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ module.exports = function (content) {
7373

7474
var result
7575
if (type === 'script') {
76-
// Pad the source code with extra blank lines
77-
// so the source-mapped line numbers corresponds to
78-
// the original *.vue file.
79-
result = padLines(content.slice(0, start)) + content.slice(start, end)
76+
result =
77+
commentScript(content.slice(0, start), lang) +
78+
content.slice(start, end) +
79+
commentScript(content.slice(end), lang)
8080
} else {
8181
result = content.slice(start, end).trim()
8282
}
@@ -91,10 +91,26 @@ module.exports = function (content) {
9191
cb(null, 'module.exports = ' + JSON.stringify(output))
9292
}
9393

94-
function padLines (content) {
94+
function commentScript (content, lang) {
9595
return content
9696
.split(/\n\r|\n|\r/g)
97-
.map(function (line) { return '' })
97+
.map(function (line) {
98+
if (line.trim() === '') {
99+
return line
100+
}
101+
102+
switch (lang) {
103+
case 'coffee':
104+
case 'coffee-jsx':
105+
case 'coffee-redux':
106+
return '# ' + line
107+
case 'purs':
108+
case 'ulmus':
109+
return '-- ' + line
110+
default:
111+
return '// ' + line
112+
}
113+
})
98114
.join('\n')
99115
}
100116

0 commit comments

Comments
 (0)