Skip to content

Use prettier from the current project instead of the bundled version #16

Closed

Description

@mderazon

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

Activity

  1. jesperbjensen commented on May 22, 2018

    @jesperbjensen
    Collaborator

    I think this is a good idea.

    I see two ways we could implement this:

    1. Settings page where you can choose to use the bundled version or the one installed in your project
    2. Look for a package.json and then look if prettier is installed - if so - use that.

    If someone wants to help out with this one, they are very welcome.

  2. tommck commented on Jun 11, 2018

    @tommck
    Contributor

    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.

  3. jesperbjensen commented on Jun 12, 2018

    @jesperbjensen
    Collaborator

    @tommck that would be awesome! 🎉🎊🤴

  4. tommck commented on Jun 12, 2018

    @tommck
    Contributor

    @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?

  5. jesperbjensen commented on Jun 12, 2018

    @jesperbjensen
    Collaborator

    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:

    1. find current directory of file
    2. Is there a package.json?
      3a. If so - find the cmd in node_modules
      3b. If not, move a level up and try again.

    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.

  6. tommck commented on Jul 14, 2018

    @tommck
    Contributor

    Alright, it's been a month, but I'm going to start working on this now. Wish me luck :)

  7. tommck commented on Jul 14, 2018

    @tommck
    Contributor

    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

  8. tommck commented on Jul 14, 2018

    @tommck
    Contributor

    Hmm.. I didn't update the version number

  9. added a commit that references this issue on Jul 14, 2018
  10. tommck commented on Jul 15, 2018

    @tommck
    Contributor

    With that PR being merged, this issue should be closed

  11. tommck commented on Jul 17, 2018

    @tommck
    Contributor

    Hey @madskristensen, since you accepted the PR, could you close this too?

  12. tommck commented on Jul 25, 2018

    @tommck
    Contributor

    @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

  13. madskristensen commented on Jul 25, 2018

    @madskristensen
    Owner

    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

  14. tommck commented on Jul 26, 2018

    @tommck
    Contributor

    Thanks for answering things on paternity leave. Totally unnecessary.
    Also: Congratulations! :)

    Maybe we can coordinate a few things when you get back?

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions