Skip to content

Commit 8466c88

Browse files
committed
Only patch minified css icons
1 parent 8b2b247 commit 8466c88

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/bin/only-include-used-icons.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -470,14 +470,14 @@ async function main() {
470470
await rm(nextCacheDir, { "recursive": true, "force": true });
471471
};
472472

473+
console.log({ dsfrDistInPublicDirPath });
474+
473475
[dsfrDistInNodeModulesDirPath, dsfrDistInPublicDirPath]
474476
.filter(exclude(undefined))
475477
.forEach(async dsfrDistDirPath => {
476-
const cssFilePaths = ["icons.css", "icons.min.css"].map(cssFileBasename =>
477-
pathJoin(dsfrDistDirPath, "utility", "icons", cssFileBasename)
478-
);
478+
const cssFilePath = pathJoin(dsfrDistDirPath, "utility", "icons", "icons.min.css");
479479

480-
if (cssFilePaths.some(cssFilePath => !fs.existsSync(cssFilePath))) {
480+
if (!fs.existsSync(cssFilePath)) {
481481
return;
482482
}
483483

@@ -497,19 +497,17 @@ async function main() {
497497
)
498498
);
499499

500-
cssFilePaths.forEach(async filePath => {
501-
log?.(`Patching ${pathRelative(projectDirPath, filePath)}`);
500+
log?.(`Patching ${pathRelative(projectDirPath, cssFilePath)}`);
502501

503-
const currentCode = await readFile(filePath);
502+
const currentCode = await readFile(cssFilePath);
504503

505-
if (Buffer.compare(rawIconCssCodeBuffer, currentCode) === 0) {
506-
return;
507-
}
504+
if (Buffer.compare(rawIconCssCodeBuffer, currentCode) === 0) {
505+
return;
506+
}
508507

509-
onConfirmedChange();
508+
onConfirmedChange();
510509

511-
writeFile(filePath, rawIconCssCodeBuffer);
512-
});
510+
writeFile(cssFilePath, rawIconCssCodeBuffer);
513511
});
514512
}
515513

0 commit comments

Comments
 (0)