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

Passing file descriptor numbers to avoid tempfiles #100

Open
lassik opened this issue Oct 21, 2018 · 2 comments
Open

Passing file descriptor numbers to avoid tempfiles #100

lassik opened this issue Oct 21, 2018 · 2 comments
Assignees

Comments

@lassik
Copy link
Contributor

lassik commented Oct 21, 2018

Continuing from #82 (comment)

The file descriptor support seemed weird at first but it's starting to grow on me. Tempfiles are the bane of inter-process communication. It's much cleaner to pass everything around with pipes. If we support routing output to arbitrary file descriptors, callers can create a pipe for every kind of output they need, then just assign the pipes to pre-determined file descriptors and tell unibeautify about those fd numbers. No tempfiles ever 🎉

And from #82 (comment)

No tempfiles ever 🎉

@lassik A goal I share. I'd be open to receiving a Pull Request implementing this. Of course, we need to continue support for Linux, Mac, and Windows.

Linux, Mac and all other unixes are easy - passing around file descriptor numbers has a long history there and the relevant APIs are extremely stable.

After investigating for a bit, I think it can be done the same way one Windows, but not sure if there are any gotchas.

@Glavin001
Copy link
Member

This is actually an implementation detail of each individual beautifier -- not specific to Unibeautify CLI or even Unibeautify core itself. Ideally, we don't use anything except stdin and stdout, however, for too many beautifiers this is not an option 😢. Therefore, this issue is more so a discussion of the best practice for developing beautifiers and then each beautifier which is currently afflicted with temporary files should be migrated towards the best practice.

@lassik
Copy link
Contributor Author

lassik commented Oct 23, 2018

Ah, I thought people who call our CLI would benefit from having the option to use arbitrary file descriptors of their choosing. I agree that we should definitely call the beautifiers using stdin/stdout/stderr whenever possible. If it works at all (on Windows) then it should be quite easy to implement. It's definitely easy on Unix if Node comes with an OS API of similar scope to e.g. Python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants