This repository was archived by the owner on Oct 30, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ const filenameToInterfaceName = (filename) => {
6
6
. replace ( / \W + ( \w ) / g, ( _ , c ) => c . toUpperCase ( ) ) ;
7
7
} ;
8
8
9
- const cssModuleToTypescriptInterfaceProperties = ( cssModuleObject , indent = ' ' ) => {
10
- return Object . keys ( cssModuleObject )
9
+ const cssModuleToTypescriptInterfaceProperties = ( cssModuleKeys , indent = ' ' ) => {
10
+ return cssModuleKeys
11
11
. map ( ( key ) => `${ indent } '${ key } ': string;` )
12
12
. join ( '\n' ) ;
13
13
} ;
@@ -18,9 +18,9 @@ export const filenameToTypingsFilename = (filename) => {
18
18
return path . join ( dirName , `${ baseName } .d.ts` ) ;
19
19
} ;
20
20
21
- export const generateInterface = ( cssModuleObject , filename , indent ) => {
21
+ export const generateInterface = ( cssModuleKeys , filename , indent ) => {
22
22
const interfaceName = filenameToInterfaceName ( filename ) ;
23
- const interfaceProperties = cssModuleToTypescriptInterfaceProperties ( cssModuleObject , indent ) ;
23
+ const interfaceProperties = cssModuleToTypescriptInterfaceProperties ( cssModuleKeys , indent ) ;
24
24
return (
25
25
`export interface ${ interfaceName } {
26
26
${ interfaceProperties }
Original file line number Diff line number Diff line change @@ -27,11 +27,12 @@ module.exports = function(input) {
27
27
28
28
// mock async step 2 - offer css loader a "fake" callback
29
29
this . async = ( ) => ( err , content ) => {
30
- const cssmodules = this . exec ( content , this . resource ) ;
31
30
const requestedResource = this . resourcePath ;
32
-
33
31
const cssModuleInterfaceFilename = filenameToTypingsFilename ( requestedResource ) ;
34
- const cssModuleInterface = generateInterface ( cssmodules , requestedResource ) ;
32
+
33
+ let cssModuleKeys = Object . keys ( this . exec ( content , this . resource ) ) ;
34
+
35
+ const cssModuleInterface = generateInterface ( cssModuleKeys , requestedResource ) ;
35
36
persist . writeToFileIfChanged ( cssModuleInterfaceFilename , cssModuleInterface ) ;
36
37
// mock async step 3 - make `async` return the actual callback again before calling the 'real' css-loader
37
38
delegateToCssLoader ( this , input , callback ) ;
You can’t perform that action at this time.
0 commit comments