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

Prevent creating folder if input and output file paths are the same #55

Merged
merged 2 commits into from Oct 5, 2021

Conversation

jfmengels
Copy link
Contributor

I'm looking into ways to make elm-optimize-level-2 faster and this looked like an easy win, though it will likely not change a lot. This will likely be how I run elm-optimize-level-2 in elm-review (it is in a branch), and I imagine others will as well.

@jfmengels
Copy link
Contributor Author

I updated the check to prevent creating the folder when the folder for the input and output are the same. The diff is now much smaller. In the best case, it adds a call to path.dirname but removes a call to fs.existsSync which would be a lot slower. In the worst case, it would only add a call to path.dirname.

@mdgriffith
Copy link
Owner

Ah interesting. I didn't realize existsSync was slow, but I guess that makes sense.

@mdgriffith mdgriffith merged commit 8e61bed into mdgriffith:master Oct 5, 2021
@jfmengels jfmengels deleted the no-unnecessary-mkdir branch December 31, 2021 09:53
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.

None yet

2 participants