@@ -8,7 +8,7 @@ import * as fs from "fs";
8
8
import { join as pathJoin } from "path" ;
9
9
import { assert } from "tsafe/assert" ;
10
10
import { exclude } from "tsafe/exclude" ;
11
- import { writeFile , readFile } from "fs/promises" ;
11
+ import { writeFile , readFile , rm } from "fs/promises" ;
12
12
import { crawl } from "./tools/crawl" ;
13
13
import { basename as pathBasename } from "path" ;
14
14
import type { Equals } from "tsafe" ;
@@ -149,6 +149,16 @@ import type { Equals } from "tsafe";
149
149
"utf8"
150
150
) ;
151
151
152
+ const onConfirmedChange = async ( ) => {
153
+ const nextCacheDir = pathJoin ( cwd , ".next" , "cache" ) ;
154
+
155
+ if ( ! fs . existsSync ( nextCacheDir ) ) {
156
+ return ;
157
+ }
158
+
159
+ rm ( nextCacheDir , { "recursive" : true , "force" : true } ) ;
160
+ } ;
161
+
152
162
[
153
163
dsfrDistDirPath ,
154
164
...( ( ) => {
@@ -173,11 +183,18 @@ import type { Equals } from "tsafe";
173
183
)
174
184
) ;
175
185
176
- [ "icons.css" , "icons.min.css" ] . forEach ( cssFileBasename =>
177
- writeFile (
178
- pathJoin ( dsfrDistDirPath , "utility" , "icons" , cssFileBasename ) ,
179
- rawIconCssCodeBuffer
180
- )
181
- ) ;
186
+ [ "icons.css" , "icons.min.css" ] . forEach ( async cssFileBasename => {
187
+ const filePath = pathJoin ( dsfrDistDirPath , "utility" , "icons" , cssFileBasename ) ;
188
+
189
+ const currentCode = await readFile ( filePath ) ;
190
+
191
+ if ( Buffer . compare ( rawIconCssCodeBuffer , currentCode ) === 0 ) {
192
+ return ;
193
+ }
194
+
195
+ onConfirmedChange ( ) ;
196
+
197
+ writeFile ( filePath , rawIconCssCodeBuffer ) ;
198
+ } ) ;
182
199
} ) ;
183
200
} ) ( ) ;
0 commit comments