open Fnm;
open Lwt.Infix;
let run = (~version) => {
let%lwt matchingLocalVersions =
LocalVersionResolver.getMatchingLocalVersions(version);
switch (matchingLocalVersions) {
| [] =>
Logger.error(
"The version "
version
" is not installed."
,
);
Lwt.return_error(1);
| [installedVersion] =>
Logger.debug(
"Uninstalling node "
Versions.Local.(installedVersion.name)
,
);
let%lwt _ = Versions.Local.remove(installedVersion);
Logger.info(
"Node version "
Versions.Local.(installedVersion.name)
" has correctly been removed."
,
);
Lwt.return_ok();
| _ =>
Logger.info(
"There are multiple versions matching your criteria:" ,
);
matchingLocalVersions
|> List.iter(matchingVersion =>
Logger.info(
Versions.Local.(matchingVersion.name)
,
)
);
Logger.info(
"\nPlease run the command again with the correct version."
,
);
Lwt.return_error(1);
};
};