@@ -70,7 +70,7 @@ class ImageOptimizer {
70
70
ensureDirSync ( `${ dir } /${ MIN_FOLDER } ` )
71
71
}
72
72
73
- this . #queue. push ( ( ) => this . #processFile( file , output , this . #context ) )
73
+ this . #queue. push ( ( ) => this . #processFile( file , output ) )
74
74
}
75
75
76
76
if ( isFolder ( file . path ) ) {
@@ -115,10 +115,7 @@ class ImageOptimizer {
115
115
}
116
116
117
117
const compressedSize = getFileSize ( output )
118
- context . webContents . send (
119
- 'file-complete' ,
120
- this . #formatOutputData( file , originalSize , compressedSize )
121
- )
118
+ this . #sendToRenderer( file , originalSize , compressedSize )
122
119
resolve ( )
123
120
}
124
121
)
@@ -144,10 +141,7 @@ class ImageOptimizer {
144
141
}
145
142
146
143
const compressedSize = getFileSize ( output )
147
- context . webContents . send (
148
- 'file-complete' ,
149
- this . #formatOutputData( file , originalSize , compressedSize )
150
- )
144
+ this . #sendToRenderer( file , originalSize , compressedSize )
151
145
resolve ( )
152
146
}
153
147
)
@@ -162,10 +156,7 @@ class ImageOptimizer {
162
156
}
163
157
164
158
const compressedSize = getFileSize ( output )
165
- context . webContents . send (
166
- 'file-complete' ,
167
- this . #formatOutputData( file , originalSize , compressedSize )
168
- )
159
+ this . #sendToRenderer( file , originalSize , compressedSize )
169
160
resolve ( )
170
161
} )
171
162
break
@@ -183,10 +174,7 @@ class ImageOptimizer {
183
174
if ( err ) console . log ( err )
184
175
185
176
const compressedSize = getFileSize ( output )
186
- context . webContents . send (
187
- 'file-complete' ,
188
- this . #formatOutputData( file , originalSize , compressedSize )
189
- )
177
+ this . #sendToRenderer( file , originalSize , compressedSize )
190
178
resolve ( )
191
179
} )
192
180
} )
@@ -207,6 +195,13 @@ class ImageOptimizer {
207
195
) . toFixed ( 2 )
208
196
}
209
197
}
198
+
199
+ #sendToRenderer ( file , originalSize , compressedSize ) {
200
+ this . #context. webContents . send (
201
+ 'file-complete' ,
202
+ this . #formatOutputData( file , originalSize , compressedSize )
203
+ )
204
+ }
210
205
}
211
206
212
207
module . exports = {
0 commit comments