Skip to content

Commit 97da6f1

Browse files
committed
ci: only create font file when svg changed
1 parent d82a00b commit 97da6f1

File tree

8 files changed

+36
-17
lines changed

8 files changed

+36
-17
lines changed

packages/persona-icon/font/persona-icon.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
@font-face {
22
font-family: 'Persona Icon';
3-
src: url('../font/persona-icon.eot?7e16266e');
4-
src: url('../font/persona-icon.eot?7e16266e#iefix') format('embedded-opentype'),
5-
url('../font/persona-icon.woff2?e76938ed') format('woff2'),
6-
url('../font/persona-icon.woff?a509bf37') format('woff'),
7-
url('../font/persona-icon.ttf?a7456908') format('truetype'),
3+
src: url('../font/persona-icon.eot?0975cc70');
4+
src: url('../font/persona-icon.eot?0975cc70#iefix') format('embedded-opentype'),
5+
url('../font/persona-icon.woff2?13b1d59d') format('woff2'),
6+
url('../font/persona-icon.woff?7ae47b0b') format('woff'),
7+
url('../font/persona-icon.ttf?83fd871d') format('truetype'),
88
url('../font/persona-icon.svg?5da0a5a4#Persona%20Icon') format('svg');
99
font-weight: normal;
1010
font-style: normal;
0 Bytes
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4885d9bdd05ba16fad9562ce2c7ff5758e64bb191c4229427dea90baef895bdf
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
20 Bytes
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* eslint-disable no-console */
2+
/* eslint-disable unicorn/prefer-top-level-await */
3+
import { createFont } from './create-font.js'
4+
5+
async function main () {
6+
await createFont()
7+
}
8+
9+
void main()

packages/persona-icon/scripts/create-font.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,28 @@ export async function createFont () {
120120
buffer: svg,
121121
} = await createSVG()
122122

123-
const ttf = await createTtf(svg)
124-
const woff = await createWoff(ttf)
125-
const woff2 = await createWoff2(ttf)
126-
const eot = await createEot(ttf)
123+
await ensureFile(resolve(FONT_DIR, 'persona-icon.sha256'))
124+
125+
const oldChecksum = await readFile(resolve(FONT_DIR, 'persona-icon.sha256')).then((c) => c.toString())
126+
const newChecksum = createHash('sha256').update(svg).digest('hex')
127+
128+
if (oldChecksum !== newChecksum) {
129+
const ttf = await createTtf(svg)
130+
const woff = await createWoff(ttf)
131+
const woff2 = await createWoff2(ttf)
132+
const eot = await createEot(ttf)
133+
134+
await createCss({
135+
glyphs,
136+
svg,
137+
ttf,
138+
eot,
139+
woff,
140+
woff2,
141+
})
142+
}
127143

128-
await createCss({
129-
glyphs,
130-
svg,
131-
ttf,
132-
eot,
133-
woff,
134-
woff2,
135-
})
144+
await writeFile(resolve(FONT_DIR, 'persona-icon.sha256'), newChecksum)
136145
}
137146

138147
function hash (buffer: Buffer | string, length = 4) {

0 commit comments

Comments
 (0)