Skip to content

Commit

Permalink
fix(write): Add EOL at the end of translations files
Browse files Browse the repository at this point in the history
  • Loading branch information
freakzlike committed Jun 25, 2023
1 parent d3d10e4 commit 924fb9e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"lint": "eslint src/ tests/ --ext .ts --ignore-path .gitignore",
"lint:fix": "pnpm run lint --fix",
"demo:cli": "node bin/cli.cjs examples/namespaces/i18n-extract.config.cjs",
"release": "semantic-release --dry-run"
"release": "semantic-release"
},
"dependencies": {
"glob": "^10.2.6"
Expand Down
3 changes: 2 additions & 1 deletion src/write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ export const writeTranslations = async (
): Promise<void> => {
await Promise.all(Object.values(translationResults).map(async (languageTranslations) => {
await Promise.all(Object.values(languageTranslations).map(async ({ filePath, translations }) => {
const content = JSON.stringify(translations, undefined, 2)

const directory = dirname(filePath)
if (!existsSync(directory)) {
mkdirSync(directory, { recursive: true })
}

writeFileSync(filePath, JSON.stringify(translations, undefined, 2))
writeFileSync(filePath, `${content}\n`)
}))
}))
}
2 changes: 1 addition & 1 deletion tests/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ beforeEach(() => {
mockedMkdir.mockReset().mockReturnValue(undefined)
})

const toJSON = (v: unknown) => JSON.stringify(v, undefined, 2)
const toJSON = (v: unknown) => `${JSON.stringify(v, undefined, 2)}\n`

/**
* i18nExtract
Expand Down

0 comments on commit 924fb9e

Please sign in to comment.