Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to write a final newline #115

Closed
remss opened this issue Mar 15, 2019 · 6 comments · Fixed by #137
Closed

Add an option to write a final newline #115

remss opened this issue Mar 15, 2019 · 6 comments · Fixed by #137

Comments

@remss
Copy link

remss commented Mar 15, 2019

The final newline to the files produced should be optional.

jsonfile.writeFile(file, obj, { finalEOL: false  })
@RyanZim
Copy link
Collaborator

RyanZim commented Mar 15, 2019

What is the usecase for not wanting a final EOL?

@remss
Copy link
Author

remss commented Mar 15, 2019

Projects may have a .editorconfig with insert_final_newline = false, and nodejs script that generates files, currently using fs.writeFile(path, JSON.stringify(data, null, 4)).
So I cannot use jsonfile.writeFile(path, data, {space: 4}) now because it will add a final EOL that is not wanted.

An other reason is a library produce json files with no final EOL. When you start using node-jsonfile module internally, you don't want to change the behavior or your API.

@RyanZim
Copy link
Collaborator

RyanZim commented Jan 30, 2020

I don't really get the point of this since final EOLs are a strong Unix convention; but I would consider it if someone did a PR.

@asingh04
Copy link
Contributor

@RyanZim i would like to pick this up

@RyanZim
Copy link
Collaborator

RyanZim commented Oct 17, 2020

@asingh04 go for it.

@asingh04
Copy link
Contributor

The PR for this feature:
#137

@RyanZim RyanZim linked a pull request Oct 17, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants