Closed mderazon closed 6 years ago
I think this is a good idea.
I see two ways we could implement this:
If someone wants to help out with this one, they are very welcome.
I was thinking of trying to tackle this. So, right now it uses a hard-coded version, but I was thinking of looking solely in the root folder (either where the Project file is, or the root of the open folder) for a node_modules/.bin/prettier.cmd file, and, if we don't find it, just using the default version.
Do you see anything wrong with this approach @jesperbjensen?
P.S. Was also thinking of adding the ability to configure the default version so that it's not hard-coded 1.12.1, but a user-entered default.
@tommck that would be awesome! 🎉🎊🤴
@jesperbjensen I was thinking of trying to find the prettier.cmd file when the solution/project is initially opened, but I realized that that the solution might have many projects and I might need to have a mapping of project -> prettier.cmd path.
Do you think the speed will suck if I search every time we're running prettier?
I dont think it will be an issue. Right now we are asking prettier to look for it’s configuration file on each run - and it must walk the directory tree to do this - and we can skip that step if you find the cmd file. So that should equal up.
It must be something like:
If we ever have trouble about speed - then we should be able to cache the result per directory - on demand.
We are really just doing what node does when it parses a file - so it can’t be that slow 🙂
There should be no need to parse the package.json - I don’t even think that node does that - it just looks for the directory.
Alright, it's been a month, but I'm going to start working on this now. Wish me luck :)
So, I have it scanning for a local prettier.
I might add support for checking for a global prettier install, if I can find that
Hmm.. I didn't update the version number
With that PR being merged, this issue should be closed
Hey @madskristensen, since you accepted the PR, could you close this too?
@madskristensen are we planning on publishing a new version soon?
Actually, it's not important to me. I really want to have #6 done before I can really use it anyway :) I'm still working on that
I can release a new version as soon as I get back from paternity leave. It'll be the same version as the CI build so just use that for now
Thanks for answering things on paternity leave. Totally unnecessary. Also: Congratulations! :)
Maybe we can coordinate a few things when you get back?
Can this extension first try to see if the current project have prettier installed ? So instead of _installDir we'll look for project dir ?
Prettier versions change the output from time to time and the version that is bundled with the extension might create a different output than the one the user has installed locally in their project