From cddc84ffe33e6b03bdb805f4d45a6353a4ef32d3 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 23 Jan 2017 05:57:18 -0500 Subject: [PATCH] Make sure translator file ends with newline when saving Fixes https://github.com/zotero/scaffold/issues/37 --- chrome/content/zotero/xpcom/translation/translators.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/translation/translators.js b/chrome/content/zotero/xpcom/translation/translators.js index 52423f6e9..583a0f866 100644 --- a/chrome/content/zotero/xpcom/translation/translators.js +++ b/chrome/content/zotero/xpcom/translation/translators.js @@ -475,8 +475,12 @@ Zotero.Translators = new function() { // JSON.stringify has the benefit of indenting JSON var metadataJSON = JSON.stringify(metadata, null, "\t"); - var str = metadataJSON + "\n\n" + code, - translator; + var str = metadataJSON + "\n\n" + code; + + // Make sure file ends with newline + if (!str.endsWith('\n')) { + str += '\n'; + } var translator = Zotero.Translators.get(metadata.translatorID); var sameFile = translator && destFile == translator.path;