File tree Expand file tree Collapse file tree 1 file changed +22
-6
lines changed Expand file tree Collapse file tree 1 file changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -73,10 +73,10 @@ module.exports = function (content) {
73
73
74
74
var result
75
75
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 )
80
80
} else {
81
81
result = content . slice ( start , end ) . trim ( )
82
82
}
@@ -91,10 +91,26 @@ module.exports = function (content) {
91
91
cb ( null , 'module.exports = ' + JSON . stringify ( output ) )
92
92
}
93
93
94
- function padLines ( content ) {
94
+ function commentScript ( content , lang ) {
95
95
return content
96
96
. 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
+ } )
98
114
. join ( '\n' )
99
115
}
100
116
You can’t perform that action at this time.
0 commit comments