Skip to content

Commit 0909e0c

Browse files
TurtIeSocksclaude
andauthored
fix(build): write a trailing newline from the JSON generators (#1246)
The config sync job on v2 failed because `bun run config:env` rewrites config/custom-environment-variables.json without a trailing newline, and the pre-commit hook now runs Biome, which wants one. The committed file only had that newline because Prettier used to add it on the way past, so nothing noticed until Prettier went away. Fixing it in the generators rather than teaching Biome to ignore the file: these are text files and should end with a newline regardless of who is checking them. The same bug was sitting in three other generators, including the locales one, whose job also commits its output and would have failed the same way the first time it ran. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
1 parent 845eb7f commit 0909e0c

4 files changed

Lines changed: 5 additions & 4 deletions

File tree

packages/config/lib/scripts/genEnvConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const generateEnvConfig = async () => {
3131
resolve(
3232
`${__dirname}/../../../../config/custom-environment-variables.json`,
3333
),
34-
JSON.stringify(recursiveObjCheck(sourceConfig), null, 2),
34+
`${JSON.stringify(recursiveObjCheck(sourceConfig), null, 2)}\n`,
3535
)
3636
}
3737

packages/locales/lib/missing.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async function missingAll() {
4141
? fileName.replace('.json', '.js')
4242
: fileName,
4343
),
44-
JSON.stringify(missingKeys, null, 2),
44+
`${JSON.stringify(missingKeys, null, 2)}\n`,
4545
)
4646
log.info(TAGS.locales, fileName, 'file saved.')
4747
}),

packages/locales/lib/utils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,11 @@ function readLocaleDirectory(human = false) {
6767
async function writeJson(translations, ...directories) {
6868
try {
6969
const resolved = resolve(...directories)
70-
const file =
70+
const contents =
7171
typeof translations === 'string'
7272
? translations
7373
: JSON.stringify(translations, null, 2)
74+
const file = contents.endsWith('\n') ? contents : `${contents}\n`
7475

7576
await fs.writeFile(resolved, file, 'utf8')
7677
log.info(TAGS.locales, 'wrote file', `${resolved.split('/').pop()}`)

packages/masterfile/lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const generate = async (save = false, historicRarity = {}, dbRarity = {}) => {
6969
if (save) {
7070
await fs.promises.writeFile(
7171
resolve(`${__dirname}/data/masterfile.json`),
72-
JSON.stringify(newMf, null, 2),
72+
`${JSON.stringify(newMf, null, 2)}\n`,
7373
'utf8',
7474
)
7575
}

0 commit comments

Comments
 (0)