|
|
|
@ -2,33 +2,36 @@ open Fnm;
@@ -2,33 +2,36 @@ open Fnm;
|
|
|
|
|
|
|
|
|
|
let run = (~name, ~version) => { |
|
|
|
|
let version = Versions.format(version); |
|
|
|
|
let versionPath = |
|
|
|
|
Filename.concat( |
|
|
|
|
Filename.concat(Directories.nodeVersions, version), |
|
|
|
|
"installation", |
|
|
|
|
); |
|
|
|
|
let%lwt versionInstalled = Lwt_unix.file_exists(versionPath); |
|
|
|
|
let%lwt matchingLocalVersions = |
|
|
|
|
LocalVersionResolver.getMatchingLocalVersions(version); |
|
|
|
|
|
|
|
|
|
if (!versionInstalled) { |
|
|
|
|
Logger.error( |
|
|
|
|
<Pastel color=Pastel.Red> |
|
|
|
|
"Can't find a version installed in " |
|
|
|
|
versionPath |
|
|
|
|
</Pastel>, |
|
|
|
|
); |
|
|
|
|
Lwt.return_error(1); |
|
|
|
|
} else { |
|
|
|
|
switch (Base.List.hd(matchingLocalVersions)) { |
|
|
|
|
| Some(latestMatchingLocalVersion) => |
|
|
|
|
Logger.info( |
|
|
|
|
<Pastel> |
|
|
|
|
"Aliasing " |
|
|
|
|
<Pastel color=Pastel.Cyan> name </Pastel> |
|
|
|
|
" to " |
|
|
|
|
<Pastel color=Pastel.Cyan> version </Pastel> |
|
|
|
|
<Pastel color=Pastel.Cyan> {latestMatchingLocalVersion.name} </Pastel> |
|
|
|
|
</Pastel>, |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
let%lwt () = Versions.Aliases.set(~alias=name, ~versionPath); |
|
|
|
|
|
|
|
|
|
let%lwt () = |
|
|
|
|
Versions.Aliases.set( |
|
|
|
|
~alias=name, |
|
|
|
|
~versionPath= |
|
|
|
|
Filename.concat( |
|
|
|
|
latestMatchingLocalVersion.fullPath, |
|
|
|
|
"installation", |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
Lwt.return_ok(); |
|
|
|
|
| None => |
|
|
|
|
Logger.error( |
|
|
|
|
<Pastel color=Pastel.Red> |
|
|
|
|
"No installed versions found that match your criteria." |
|
|
|
|
</Pastel>, |
|
|
|
|
); |
|
|
|
|
Lwt.return_error(1); |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|