File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -4,17 +4,27 @@ import path from "path";
4
4
import postcss from "postcss" ;
5
5
import { replaceSymbols , replaceValueSymbols , extractICSS } from "icss-utils" ;
6
6
7
+ const readFile = filepath =>
8
+ new Promise ( ( resolve , reject ) => {
9
+ fs . readFile ( filepath , "utf-8" , ( err , content ) => {
10
+ if ( err ) {
11
+ reject ( err ) ;
12
+ } else {
13
+ resolve ( content ) ;
14
+ }
15
+ } ) ;
16
+ } ) ;
17
+
7
18
const defaultFetch = ( importee , importerDir , processor ) => {
8
19
const ext = path . extname ( importee ) ;
9
20
if ( ext !== ".css" ) {
10
21
return Promise . resolve ( {
11
- default : `' ${ importee } '`
22
+ default : importee
12
23
} ) ;
13
24
}
14
25
const from = path . resolve ( importerDir , importee ) ;
15
- const content = fs . readFileSync ( from , "utf-8" ) ;
16
- return processor
17
- . process ( content , { from } )
26
+ return readFile ( from )
27
+ . then ( content => processor . process ( content , { from } ) )
18
28
. then ( result => result . messages . find ( d => d . type === "icss" ) . exportTokens ) ;
19
29
} ;
20
30
Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ test("import non-css files as resource", () => {
72
72
` )
73
73
) . resolves . toEqual (
74
74
strip ( `
75
- .foo { background: url(' path/to/resource.png' ) }
75
+ .foo { background: url(path/to/resource.png) }
76
76
` )
77
77
) ;
78
78
} ) ;
You can’t perform that action at this time.
0 commit comments