Skip to content

Commit 5f98004

Browse files
committed
Readme automation.
1 parent 2c75013 commit 5f98004

2 files changed

Lines changed: 43 additions & 3 deletions

File tree

mdat.config.ts

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,43 @@
11
import { mdatConfig } from '@kitschpatrol/mdat-config'
2+
import { execFileSync } from 'node:child_process'
3+
import { open } from 'node:fs/promises'
24

3-
export default mdatConfig()
5+
function getGitLastModified(filePath: string): Date {
6+
const stdout = execFileSync('git', ['log', '-1', '--format=%ci', '--', filePath], {
7+
encoding: 'utf8',
8+
})
9+
10+
return new Date(stdout.trim())
11+
}
12+
13+
async function countLines(filePath: string): Promise<number> {
14+
const file = await open(filePath, 'r')
15+
let count = 0
16+
17+
try {
18+
for await (const chunk of file.readableWebStream()) {
19+
// eslint-disable-next-line ts/no-unsafe-type-assertion
20+
const bytes = chunk as Uint8Array
21+
for (const byte of bytes) {
22+
if (byte === 0x0a) count++
23+
}
24+
}
25+
} finally {
26+
await file.close()
27+
}
28+
29+
return count
30+
}
31+
32+
export default mdatConfig({
33+
rules: {
34+
'update-date'() {
35+
const updateDate = getGitLastModified('./src/en-wiktionary.txt')
36+
return updateDate.toLocaleDateString('en-US', { month: 'long', year: 'numeric' })
37+
},
38+
async 'word-count'() {
39+
const wordCount = await countLines('./src/en-wiktionary.txt')
40+
return wordCount.toLocaleString('en-US')
41+
},
42+
},
43+
})

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
## Overview
2323

24-
This is a pre-built [CSpell](https://cspell.org/) dictionary with 800k+ English words sampled from the [Wiktionary](https://en.wiktionary.org/wiki/Wiktionary:Main_Page) project in November 2025.
24+
This is a pre-built [CSpell](https://cspell.org/) dictionary with <!-- word-count -->913,922<!-- /word-count --> English words sampled from the [Wiktionary](https://en.wiktionary.org/wiki/Wiktionary:Main_Page) project in <!-- update-date -->January 2026<!-- /update-date -->.
2525

2626
## Getting started
2727

@@ -94,7 +94,7 @@ No censorship and _almost_ no curation is performed when generating the dictiona
9494
See the [generate-dictionary.ts](/scripts/generate-dictionary.ts) script for additional
9595
details.
9696

97-
My intention is to update this dictionary with the latest words from Wiktionary at least once a year.
97+
My intention is to update this dictionary with the latest words from Wiktionary at least once a year. (The mose recent update was in <!-- update-date -->January 2026<!-- /update-date -->.)
9898

9999
## Maintainers
100100

0 commit comments

Comments
 (0)