-
Notifications
You must be signed in to change notification settings - Fork 484
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
skip installation if the version is already installed #27
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woah! @kentac55! thanks for the contribution 😸
This is a very good feature and I think we can polish it a bit and then merge it because it is a very good idea.
Another idea, that may not fit for right now - is adding a --reinstall
flag
About ANSI, I totally agree with you. Kinda annoying that we force colors all the time, but I think removing the ANSI codes shouldn't be on our input, but our output. Maybe we should have something like Chalk's supports-color
? I'm opening a new issue for that matter, so let's focus this PR on the "already installed" part
This reverts commit 9e5b27f.
@Schniz Thank you for your reviewing! And sorry for my confusing(it's my first time to write reasonml(and ocaml) 😵 and I misread your review... 😰 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, everything is good! I'm trying not to nitpick so if I'm too annoying just tell me 😄
I have added some comments, and I'm sorry I haven't addressed this beforehand. I guess the code will be cleaner after some slight changes - I'd like to know what you think about it too
Thanks again, my friend! I'm thankful for your contribution and welcome to our community 🌮
let throwIfInstalled = versionName => { | ||
getInstalledVersions() | ||
|> Result.fold( | ||
_ => Lwt.return(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we would fold it to an empty array, we could push down the knowledge of Lwt and take out one indentation level:
let installed = getInstalledVersions()
|> Result.fold(_ => [||], xs => xs) // would return an empty array for errors
|> Array.exists(x => Local.(x.name == versionName))
if (installed) {
Lwt.fail(Already_installed(versionName));
} else {
Lwt.return();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that being said, I'm really not sure we need to even care about Lwt here. We can stick to isVersionInstalled
like you mentioned before that, and leave the logic of throwing an error to the executable itself (which also handles the error):
// library/Versions.re
let isVersionInstalled = versionName =>
getInstalledVersions()
|> Result.fold(_ => [||], xs => xs) // would return an empty array for errors
|> Array.exists(x => Local.(x.name == versionName));
// executable/Install.re
let%lwt _ = if (Versions.isVersionInstalled(someVersion)) {
Lwt.fail(Already_installed(someVersion));
} else {
Lwt.return();
}
Now that I think about it, in #30 I'm making |
@kentac55, thanks for all your hard work 😄 🏆 🌮 |
@Schniz Sorry for late response. I was too busy to response this PR in few days. Thanks for fix and merge it and taught reasonml for me. |
1. When install specify version fromfnm ls-remote
, the version which has been installed contains ANSI codes andfnm install
raise internal error.i reverted it.