From 9cf76bb9dcecb21c137b63818834e4b053748a7d Mon Sep 17 00:00:00 2001 From: Pavel Lang Date: Mon, 25 Apr 2016 16:31:54 +0200 Subject: [PATCH 1/2] Write newline on end of messages file --- tools/extractMessages.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/extractMessages.js b/tools/extractMessages.js index a82a53fa5..ca77ecf7c 100644 --- a/tools/extractMessages.js +++ b/tools/extractMessages.js @@ -19,6 +19,10 @@ const GLOB_PATTERN = 'src/**/*.{js,jsx}'; const fileToMessages = {}; let messages = {}; +async function writeMessages(fileName, messages) { + await fs.writeFile(fileName, JSON.stringify(messages, null, 2) + '\n'); +} + // merge messages to source files async function mergeToFile(locale, toBuild) { const fileName = `src/messages/${locale}.json`; @@ -56,14 +60,14 @@ async function mergeToFile(locale, toBuild) { .map(key => originalMessages[key]) .filter(msg => msg.files || msg.message); - await fs.writeFile(fileName, JSON.stringify(result, null, 2)); + await writeMessages(fileName, result); console.log(`Messages updated: ${fileName}`); if (toBuild && locale !== '_default') { const buildFileName = `build/messages/${locale}.json`; try { - await fs.writeFile(buildFileName, JSON.stringify(result, null, 2)); + await writeMessages(buildFileName, result); console.log(`Build messages updated: ${buildFileName}`); } catch (err) { console.error(`Failed to update ${buildFileName}`); From bd587c3d00e04b6da5a674fc1921f8d102e28fe2 Mon Sep 17 00:00:00 2001 From: Pavel Lang Date: Mon, 25 Apr 2016 16:32:28 +0200 Subject: [PATCH 2/2] Add newline before EOF --- src/messages/_default.json | 2 +- src/messages/cs.json | 2 +- src/messages/en.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/messages/_default.json b/src/messages/_default.json index e7b9a3c79..b1dd20fd7 100644 --- a/src/messages/_default.json +++ b/src/messages/_default.json @@ -63,4 +63,4 @@ "src/components/Navigation/Navigation.js" ] } -] \ No newline at end of file +] diff --git a/src/messages/cs.json b/src/messages/cs.json index 9c3d32764..08efe1785 100644 --- a/src/messages/cs.json +++ b/src/messages/cs.json @@ -63,4 +63,4 @@ "src/components/Navigation/Navigation.js" ] } -] \ No newline at end of file +] diff --git a/src/messages/en.json b/src/messages/en.json index e7b9a3c79..b1dd20fd7 100644 --- a/src/messages/en.json +++ b/src/messages/en.json @@ -63,4 +63,4 @@ "src/components/Navigation/Navigation.js" ] } -] \ No newline at end of file +]