@@ -32,9 +32,10 @@ const walk = async dir => {
32
32
// Exclude 'dist' directories
33
33
await walk ( fromPath ) ;
34
34
}
35
- } else if ( / ( p n g | j p g | j p e g ) $ / i. test ( file ) ) {
35
+ } else if ( / ( p n g | j p g | j p e g | g i f ) $ / i. test ( file ) ) {
36
36
Object . entries ( SIZES ) . forEach ( ( [ size , [ width , height ] ] ) => {
37
- Jimp . read ( fromPath )
37
+ if ( ! file . endsWith ( '.gif' ) ) {
38
+ Jimp . read ( fromPath )
38
39
. then ( img => {
39
40
const distDir = path . join ( dir , 'dist' , size ) ;
40
41
@@ -55,15 +56,16 @@ const walk = async dir => {
55
56
. catch ( err => {
56
57
console . error ( err ) ;
57
58
} ) ;
58
- } ) ;
59
- } else if ( / ( g i f ) $ / i. test ( file ) ) {
60
- Object . entries ( SIZES ) . forEach ( ( [ size , [ width , height ] ] ) => {
61
- const distDir = path . join ( dir , 'dist' , size ) ;
62
- GifUtil . read ( fromPath ) . then ( gif => {
63
- gif . width = width ;
64
- gif . height = height ?? Math . ceil ( ( width * gif . height ) / gif . width ) ;
65
- GifUtil . write ( path . join ( distDir , file ) , gif . frames , gif )
66
- } ) ;
59
+ } else {
60
+ GifUtil . read ( fromPath ) . then ( gif => {
61
+ const distDir = path . join ( dir , 'dist' , size ) ;
62
+ fs . ensureDir ( distDir ) . then ( ( ) => {
63
+ gif . width = width ;
64
+ gif . height = height ?? Math . ceil ( ( width * gif . height ) / gif . width ) ;
65
+ return GifUtil . write ( path . join ( distDir , file ) , gif . frames , gif )
66
+ } ) ;
67
+ } ) ;
68
+ }
67
69
} ) ;
68
70
}
69
71
}
0 commit comments