@@ -8,7 +8,7 @@ import * as fs from "fs";
88import { join as pathJoin } from "path" ;
99import { assert } from "tsafe/assert" ;
1010import { exclude } from "tsafe/exclude" ;
11- import { writeFile , readFile } from "fs/promises" ;
11+ import { writeFile , readFile , rm } from "fs/promises" ;
1212import { crawl } from "./tools/crawl" ;
1313import { basename as pathBasename } from "path" ;
1414import type { Equals } from "tsafe" ;
@@ -149,6 +149,16 @@ import type { Equals } from "tsafe";
149149 "utf8"
150150 ) ;
151151
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+
152162 [
153163 dsfrDistDirPath ,
154164 ...( ( ) => {
@@ -173,11 +183,18 @@ import type { Equals } from "tsafe";
173183 )
174184 ) ;
175185
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+ } ) ;
182199 } ) ;
183200} ) ( ) ;
0 commit comments