@@ -33,7 +33,9 @@ function execLoader(filename, callback) {
33
33
return this . callback ;
34
34
}
35
35
} ;
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 ) ;
37
39
if ( ! async ) return callback ( null , res , null , deps , warns ) ;
38
40
}
39
41
@@ -107,6 +109,24 @@ describe("source-map-loader", function() {
107
109
done ( ) ;
108
110
} ) ;
109
111
} ) ;
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
+ } ) ;
110
130
it ( "should warn on missing SourceMap" , function ( done ) {
111
131
execLoader ( path . join ( __dirname , "fixtures" , "missing-source-map.js" ) , function ( err , res , map , deps , warns ) {
112
132
should . equal ( err , null ) ;
0 commit comments