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

Speed up calling elm-format by not using npx #49

Merged
merged 2 commits into from
May 30, 2021

Conversation

lydell
Copy link
Contributor

@lydell lydell commented May 29, 2021

npx elm-format is used to call elm-format. npx takes about 200 ms to boot.

This PR removes the use of npx for elm-format, speeding things up. This is an implementation of #46 (comment) (only the elm-format bits), but done in a backwards compatible way. As a bonus, this gets rid of the command injection issue reported in #46 (but not the one in elm-review new-package).

I’ve tested manually on macOS and Windows, and it seems to work just like intended. Jeroen has tested on Linux.

@@ -79,6 +79,7 @@
"got": "^10.7.0",
"minimist": "^1.2.0",
"ora": "^5.4.0",
"path-key": "^3.1.1",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cross-spawn already depends on this module at the same version, so this is only making a sub-dependency a “real” dependency.

Copy link
Owner

@jfmengels jfmengels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very good! I tried it on Ubuntu and it's working very well 👍
In my testing, the average time went from ~1550ms to ~1250ms (sometimes even less) for a single spawn of elm-format, so I'm thinking your underplayed the 200ms delay 😅

Did you mark this as draft because you haven't tested it on Windows yet? Do you have a Windows available?

lib/autofix.js Outdated Show resolved Hide resolved
@lydell
Copy link
Contributor Author

lydell commented May 29, 2021

Yes, I marked as draft since I wanted to test more first. I have Windows available, but I’m too tired to test tonight.

@lydell lydell marked this pull request as ready for review May 30, 2021 09:03
@lydell
Copy link
Contributor Author

lydell commented May 30, 2021

I’ve tested on Windows now. Seems to work perfectly!

@jfmengels jfmengels merged commit 5669aef into jfmengels:master May 30, 2021
@jfmengels
Copy link
Owner

Awesome, thanks a lot for this!

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

Successfully merging this pull request may close these issues.

2 participants