prettier-cli icon indicating copy to clipboard operation
prettier-cli copied to clipboard

feat: reuse format options logic for stdin

Open 43081j opened this issue 1 year ago • 5 comments

This is a first attempt at re-using the format options logic when stdin mode has been given a file path.

There is still code clean up to do, but this should roughly work.

43081j avatar Feb 08 '25 15:02 43081j

I think we shouldn't have utility functions in index.ts. If we can do this with minimal changes it would be great 🤔

fabiospampinato avatar Feb 09 '25 17:02 fabiospampinato

yep I agree. I planned on moving them out before publishing this pr, so will do that once I'm back from London this week 👍

43081j avatar Feb 09 '25 18:02 43081j

Worth considering trying to not have them in the first place if possible, this change seems kinda big and kinda disruptive 🤔

fabiospampinato avatar Feb 09 '25 18:02 fabiospampinato

how else can you do it?

the logic in there right now is very intertwined. lots of logic crossing paths, making it difficult to extract without repeating some things

you'd rather duplicate all of it into the stdin function? 🤔

43081j avatar Feb 09 '25 18:02 43081j

Maybe there isn't a less disruptive way, I'm not sure what the solution is exactly 🤔

I think I'd want to explore how to map the stdin with ~filepath code path into the globs code path, like maybe processing stdin with ~filepath in some way is kinda like searching with a very specific glob, and making sure a result is "found" for it even if not in the filesystem, and maybe bypassing the cache, and a couple very minor tweaks like that? 🤔

I think we should explore doing it that way if possible at all, to not majorly change the code.

fabiospampinato avatar Feb 09 '25 18:02 fabiospampinato