Browse Source

Fix aliases (#103)

remotes/origin/add-simple-redirecting-site
Gal Schlezinger 6 years ago committed by GitHub
parent
commit
ae336a7a3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      executable/Use.re
  2. 12
      library/Versions.re

7
executable/Use.re

@ -29,7 +29,6 @@ let switchVersion = (~version, ~quiet) => {
| System => "system" | System => "system"
}; };
let destination = Filename.concat(versionPath, "installation");
let source = Directories.currentVersion; let source = Directories.currentVersion;
log( log(
@ -37,17 +36,17 @@ let switchVersion = (~version, ~quiet) => {
"Linking " "Linking "
<Pastel color=Pastel.Cyan> source </Pastel> <Pastel color=Pastel.Cyan> source </Pastel>
" to " " to "
<Pastel color=Pastel.Cyan> destination </Pastel> <Pastel color=Pastel.Cyan> versionPath </Pastel>
</Pastel>, </Pastel>,
); );
let%lwt _ = Lwt_unix.unlink(Directories.currentVersion) |> lwtIgnore; let%lwt _ = Lwt_unix.unlink(Directories.currentVersion) |> lwtIgnore;
let%lwt _ = Lwt_unix.symlink(destination, Directories.currentVersion) let%lwt _ = Lwt_unix.symlink(versionPath, Directories.currentVersion)
and defaultAliasExists = Lwt_unix.file_exists(Directories.defaultVersion); and defaultAliasExists = Lwt_unix.file_exists(Directories.defaultVersion);
let%lwt _ = let%lwt _ =
if (!defaultAliasExists) { if (!defaultAliasExists) {
Versions.Aliases.set(~alias="default", ~versionPath=destination); Versions.Aliases.set(~alias="default", ~versionPath);
} else { } else {
Lwt.return(); Lwt.return();
}; };

12
library/Versions.re

@ -31,9 +31,17 @@ module Local = {
aliases: list(string), aliases: list(string),
}; };
let systemVersion: t = {name: "system", fullPath: "/dev/null", aliases: []}; let systemVersion: t = {
name: "system",
fullPath: "/dev/null/installation",
aliases: [],
};
let toDirectory = name => Filename.concat(Directories.nodeVersions, name); let toDirectory = name =>
Filename.concat(
Filename.concat(Directories.nodeVersions, name),
"installation",
);
let remove = version => Fs.rmdir(version.fullPath); let remove = version => Fs.rmdir(version.fullPath);

Loading…
Cancel
Save