Code Monkey home page Code Monkey logo

Comments (9)

igitur avatar igitur commented on July 20, 2024 4

Lots of debugging but I got closer. Because I'm using prettier and its plugins via a require(), I have install them in the project folder, which in this case is /home/runner/work/react-wordle/react-wordle/. Reference: https://docs.npmjs.com/cli/v8/configuring-npm/folders/ (Install it locally if you're going to require() it.).

But for some reason (and I can't figure out why), everything that is installed locally gets installed to /home/runner/work/_actions/creyD/prettier_action/v4.2/.

npm prefix yields /home/runner/work/_actions/creyD/prettier_action/v4.2/ so clearly npm believes that is the 'local' folder. A pwd yields /home/runner/work/react-wordle/react-wordle/ so I don't understand why the difference.

And it's this discrepancy between the 2 directories that makes prettier unable to find the plugin module.

I solved this by amending my lint.yml Github actions file to run a npm install first (I have prettier and the plugins in my package.json too). This works for me, but for people who don't have the library entries in a package.json this won't work and I still believe there must a be more elegant solution.

from prettier_action.

creyD avatar creyD commented on July 20, 2024 1

It should be possible to do it like this: prettier_plugins: '@trivago/prettier-plugin-sort-imports prettier-plugin-tailwindcss --global'

from prettier_action.

creyD avatar creyD commented on July 20, 2024

Maybe we would need to install the plugins globally to be used with a config?

from prettier_action.

igitur avatar igitur commented on July 20, 2024

@creyD Is there anything I can do from my side to check that?

from prettier_action.

igitur avatar igitur commented on July 20, 2024

No, that unfortunately doesn't work.
image

Looks like the @trivago/prettier-plugin-sort-imports prettier-plugin-tailwindcss --global is implicitly parsed as 3 separate strings.

from prettier_action.

igitur avatar igitur commented on July 20, 2024

I can try submit a PR to add a new option to install prettier and/or its plugins globally, but how does one test GitHub actions locally?

from prettier_action.

creyD avatar creyD commented on July 20, 2024

@igitur That's very generous of you to offer, thanks a lot! I myself didn't find a way yet, at least not with the way this action is built (I think docker based actions are more easily tested). What I always do is to create a separate test repo with just one js file in it and the action configured to creyd/prettier_action@latest (you would need to replace the username with your own name to test against your own action and you could exchange latest with any version statement or a branch etc). Hope this helps!

from prettier_action.

creyD avatar creyD commented on July 20, 2024

How would you advise to go forward? @igitur Should we mark this issue as solved or are you still working on a fix?

from prettier_action.

igitur avatar igitur commented on July 20, 2024

Happy to close this.

from prettier_action.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.