Browse Source

Use exit code 1 on errors on `fnm use`. Fixes #43 (#45)

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

21
executable/Use.re

@ -69,14 +69,27 @@ let run = (~version, ~quiet) => @@ -69,14 +69,27 @@ let run = (~version, ~quiet) =>
"The following version is not installed: "
version
</Pastel>,
)
|> Lwt.return
);
exit(1);
| Dotfiles.Conflicting_Dotfiles_Found(v1, v2) =>
log(
~quiet,
<Pastel color=Pastel.Red>
"Can't infer version from dotfiles: .node-version and .nvmrc have differing version strings:\n"
" * "
v1
"\n"
" * "
v2
</Pastel>,
);
exit(1);
| Dotfiles.Version_Not_Provided =>
log(
~quiet,
<Pastel color=Pastel.Red>
"No .nvmrc or .node-version file was found in the current directory. Please provide a version number."
</Pastel>,
)
|> Lwt.return
);
exit(1);
};

5
library/Dotfiles.re

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
exception Version_Not_Provided;
exception Conflicting_Dotfiles_Found(string, string);
let versionString = fileName => {
try%lwt (
@ -20,9 +21,7 @@ let getVersion = () => { @@ -20,9 +21,7 @@ let getVersion = () => {
switch (nodeVersion, nvmrc) {
| (None, None) => Lwt.fail(Version_Not_Provided)
| (Some(v1), Some(v2)) when v1 != v2 =>
Lwt.fail_with(
"You have both .node-version and .nvmrc with differing version strings!",
)
Lwt.fail(Conflicting_Dotfiles_Found(v1, v2))
| (Some(version), Some(_))
| (Some(version), None)
| (None, Some(version)) => Lwt.return(version)

Loading…
Cancel
Save