Feature: Add config for newline at the end of generated JSONs
CapoD opened this issue · 5 comments
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe
JSON files created by transloco-keys-manager extract
do not have new lines at the end which collides with Unix best practices (e.g. Why Should Text Files End With a Newline in Linux).
Describe the solution you'd like
Add a configuration parameter to add new lines at JSON EOF.
Describe alternatives you've considered
No response
Describe alternatives you've considered
ignore the topic 🥺
always add new lines to the EOF which might create legacy problems
Describe alternatives you've considered
always add new lines to the EOF which might create legacy problems
Additional context
No response
I would like to make a pull request for this feature
Yes 🚀
I face the same issue, for now I have edited my package.json
file to run extract
then prettier
It's an ugly workaround that prevent our Pull Requests tu be bloqued by invalid formatting on the translation files
We are using patch-package
to patch transloco to put a newline at the end of a generated JSON. This is quite a hack, but it works fine for us.
diff --git a/node_modules/@ngneat/transloco-keys-manager/utils/object.utils.js b/node_modules/@ngneat/transloco-keys-manager/utils/object.utils.js
index c1c3f8d..58b0bbc 100644
--- a/node_modules/@ngneat/transloco-keys-manager/utils/object.utils.js
+++ b/node_modules/@ngneat/transloco-keys-manager/utils/object.utils.js
@@ -9,7 +9,7 @@ function stringify(val) {
if (sort) {
value = sortKeys(val);
}
- return JSON.stringify(value, null, 2);
+ return JSON.stringify(value, null, 2) + "\n";
}
exports.stringify = stringify;
function sortKeys(val) {
I think that the keys manager should just run prettier at the end of the process instead of the specific option of a new line at EOF.
WDYT?
I think that the keys manager should just run prettier at the end of the process instead of the specific option of a new line at EOF. WDYT?
I agree with you, I don't think that loading the tool with too much options is a good idea. Maybe in the configuration, give the formatting tool that will be used, so all the configuration about formatting is managed by it instead of the keys-manager ?