@@ -14,7 +14,7 @@ const getNoDeclarationFileError = ({ filename }) =>
14
14
) ;
15
15
16
16
const getTypeMismatchError = ( { filename, expected, actual } ) => {
17
- const diff = new LineDiff ( actual , expected ) . toString ( ) ;
17
+ const diff = new LineDiff ( enforceLFLineSeparators ( actual ) , expected ) . toString ( ) ;
18
18
19
19
return new Error (
20
20
`Generated type declaration file is outdated. Run webpack and commit the updated type declaration for '${ filename } '\n\n${ diff } `
@@ -36,6 +36,19 @@ const filenameToTypingsFilename = filename => {
36
36
return path . join ( dirName , `${ baseName } .d.ts` ) ;
37
37
} ;
38
38
39
+ const enforceLFLineSeparators = text => {
40
+ if ( text ) {
41
+ // replace all CRLFs (Windows) by LFs (Unix)
42
+ return text . replace ( / \r \n / g, "\n" ) ;
43
+ } else {
44
+ return text ;
45
+ }
46
+ } ;
47
+
48
+ const compareText = ( contentA , contentB ) => {
49
+ return enforceLFLineSeparators ( contentA ) === enforceLFLineSeparators ( contentB ) ;
50
+ } ;
51
+
39
52
const validModes = [ 'emit' , 'verify' ] ;
40
53
41
54
const isFileNotFound = err => err && err . code === 'ENOENT' ;
@@ -91,7 +104,7 @@ module.exports = function(content, ...rest) {
91
104
return failed ( err ) ;
92
105
}
93
106
94
- if ( cssModuleDefinition !== fileContents ) {
107
+ if ( ! compareText ( cssModuleDefinition , fileContents ) ) {
95
108
return failed (
96
109
getTypeMismatchError ( {
97
110
filename : cssModuleInterfaceFilename ,
@@ -105,7 +118,7 @@ module.exports = function(content, ...rest) {
105
118
} ) ;
106
119
} else {
107
120
read ( ( _ , fileContents ) => {
108
- if ( cssModuleDefinition !== fileContents ) {
121
+ if ( ! compareText ( cssModuleDefinition , fileContents ) ) {
109
122
write ( cssModuleDefinition , err => {
110
123
if ( err ) {
111
124
failed ( err ) ;
0 commit comments