@@ -36,8 +36,12 @@ async function generateIconFiles() {
36
36
37
37
const iconNames = files . map ( file => iconName ( file ) )
38
38
39
- const spriteUpToDate = iconNames . every ( name => currentSprite . includes ( `id=${ name } ` ) )
40
- const typesUpToDate = iconNames . every ( name => currentTypes . includes ( `"${ name } "` ) )
39
+ const spriteUpToDate = iconNames . every ( name =>
40
+ currentSprite . includes ( `id=${ name } ` ) ,
41
+ )
42
+ const typesUpToDate = iconNames . every ( name =>
43
+ currentTypes . includes ( `"${ name } "` ) ,
44
+ )
41
45
42
46
if ( spriteUpToDate && typesUpToDate ) {
43
47
console . log ( `Icons are up to date` )
@@ -48,7 +52,7 @@ async function generateIconFiles() {
48
52
49
53
await fsExtra . emptyDir ( outputDir )
50
54
51
- await generateSvgSprite ( {
55
+ const changedSprite = await generateSvgSprite ( {
52
56
files,
53
57
inputDir,
54
58
outputPath : spriteFilepath ,
@@ -66,11 +70,14 @@ async function generateIconFiles() {
66
70
export type IconName =
67
71
\t| ${ stringifiedIconNames . join ( '\n\t| ' ) } ;
68
72
`
69
- await writeIfChanged ( typeOutputFilepath , typeOutputContent )
73
+ const changedTypes = await writeIfChanged (
74
+ typeOutputFilepath ,
75
+ typeOutputContent ,
76
+ )
70
77
71
78
logVerbose ( `Manifest saved to ${ path . relative ( cwd , typeOutputFilepath ) } ` )
72
79
73
- await writeIfChanged (
80
+ const changedIconReadme = await writeIfChanged (
74
81
path . join ( outputDir , 'README.md' ) ,
75
82
`# Icons
76
83
@@ -79,7 +86,9 @@ This directory contains SVG icons that are used by the app.
79
86
Everything in this directory is generated by \`npm run build:icons\`.
80
87
` ,
81
88
)
82
- console . log ( `Generated ${ files . length } icons` )
89
+ if ( changedIconReadme || changedSprite || changedTypes ) {
90
+ console . log ( `Generated ${ files . length } icons` )
91
+ }
83
92
}
84
93
85
94
function iconName ( file : string ) {
@@ -137,6 +146,6 @@ async function writeIfChanged(filepath: string, newContent: string) {
137
146
const currentContent = await fsExtra
138
147
. readFile ( filepath , 'utf8' )
139
148
. catch ( ( ) => '' )
140
- if ( currentContent === newContent ) return
149
+ if ( currentContent === newContent ) return false
141
150
await fsExtra . writeFile ( filepath , newContent , 'utf8' )
142
151
}
0 commit comments