Browse Source

skip installation if the version is already installed (#27)

* remove ansi codes from provided version string

* add check func whether the specify version is already installed or not

* Revert "remove ansi codes from provided version string"

This reverts commit 9e5b27f942e8be94c1bffda13a254f46cbf3dece.

* apply code review(rename check function)

* run esy fmt

* move short path to the top of the switch case

* use Result.fold instead of switch case

* use Array.exists instead of List.exists
remotes/origin/add-simple-redirecting-site
kentac55 6 years ago committed by Gal Schlezinger
parent
commit
a1e9266f1c
  1. 1
      executable/Install.re
  2. 13
      library/Versions.re

1
executable/Install.re

@ -27,6 +27,7 @@ let main = (~version as versionName) => {
}; };
let versionName = Versions.format(versionName); let versionName = Versions.format(versionName);
let%lwt _ = Versions.throwIfInstalled(versionName);
Console.log( Console.log(
<Pastel> <Pastel>

13
library/Versions.re

@ -8,6 +8,7 @@ module Local = {
}; };
exception Version_not_found(string); exception Version_not_found(string);
exception Already_installed(string);
module Remote = { module Remote = {
type t = { type t = {
@ -145,3 +146,15 @@ let getRemoteVersions = () => {
) )
|> Lwt.return; |> Lwt.return;
}; };
let throwIfInstalled = versionName => {
getInstalledVersions()
|> Result.fold(
_ => Lwt.return(),
xs =>
Array.exists(x => Local.(x.name == versionName), xs)
|> (
x => x ? Lwt.fail(Already_installed(versionName)) : Lwt.return()
),
);
};

Loading…
Cancel
Save