File tree Expand file tree Collapse file tree 1 file changed +32
-6
lines changed Expand file tree Collapse file tree 1 file changed +32
-6
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,15 @@ module.exports = function (content) {
7171 var start = node . childNodes [ 0 ] . __location . start
7272 var end = node . childNodes [ node . childNodes . length - 1 ] . __location . end
7373
74- var result = content . slice ( start , end ) . trim ( )
74+ var result
75+ if ( type === 'script' ) {
76+ result =
77+ commentScript ( content . slice ( 0 , start ) , lang ) +
78+ content . slice ( start , end ) +
79+ commentScript ( content . slice ( end ) , lang )
80+ } else {
81+ result = content . slice ( start , end ) . trim ( )
82+ }
7583
7684 output [ type ] . push ( {
7785 lang : lang ,
@@ -83,14 +91,32 @@ module.exports = function (content) {
8391 cb ( null , 'module.exports = ' + JSON . stringify ( output ) )
8492}
8593
86- function commentScript ( content ) {
94+ function commentScript ( content , lang ) {
8795 return content
8896 . split ( / \n \r | \n | \r / g)
8997 . map ( function ( line ) {
90- if ( line . trim ( ) === '' ) {
91- return line
92- } else {
93- return '// ' + line
98+ switch ( lang ) {
99+ case 'coffee' :
100+ case 'coffee-jsx' :
101+ case 'coffee-redux' :
102+ if ( line . trim ( ) === '' ) {
103+ return line
104+ } else {
105+ return '# ' + line
106+ }
107+ case 'purs' :
108+ case 'ulmus' :
109+ if ( line . trim ( ) === '' ) {
110+ return line
111+ } else {
112+ return '-- ' + line
113+ }
114+ default :
115+ if ( line . trim ( ) === '' ) {
116+ return line
117+ } else {
118+ return '// ' + line
119+ }
94120 }
95121 } )
96122 . join ( '\n' )
You can’t perform that action at this time.
0 commit comments