@@ -33,7 +33,9 @@ function execLoader(filename, callback) {
3333 return this . callback ;
3434 }
3535 } ;
36- var res = loader . call ( context , fs . readFileSync ( filename , "utf-8" ) ) ;
36+ // Remove CRs to make test line ending invariant
37+ var fixtureContent = fs . readFileSync ( filename , "utf-8" ) . replace ( / \r / g, '' ) ;
38+ var res = loader . call ( context , fixtureContent ) ;
3739 if ( ! async ) return callback ( null , res , null , deps , warns ) ;
3840}
3941
@@ -107,6 +109,24 @@ describe("source-map-loader", function() {
107109 done ( ) ;
108110 } ) ;
109111 } ) ;
112+ it ( "should use last SourceMap directive" , function ( done ) {
113+ execLoader ( path . join ( __dirname , "fixtures" , "multi-source-map.js" ) , function ( err , res , map , deps , warns ) {
114+ should . equal ( err , null ) ;
115+ warns . should . be . eql ( [ ] ) ;
116+ should . equal ( res , "with SourceMap\nanInvalidDirective = \"\\n/*# sourceMappingURL=data:application/json;base64,\" + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + \" */\";\n// comment" ) ,
117+ map . should . be . eql ( {
118+ "version" : 3 ,
119+ "file" : "inline-source-map.js" ,
120+ "sources" : [
121+ "inline-source-map.txt"
122+ ] ,
123+ "sourcesContent" : [ "with SourceMap" ] ,
124+ "mappings" : "AAAA"
125+ } ) ;
126+ deps . should . be . eql ( [ ] ) ;
127+ done ( ) ;
128+ } ) ;
129+ } ) ;
110130 it ( "should warn on missing SourceMap" , function ( done ) {
111131 execLoader ( path . join ( __dirname , "fixtures" , "missing-source-map.js" ) , function ( err , res , map , deps , warns ) {
112132 should . equal ( err , null ) ;
0 commit comments