Browse Source

Fixes #11: Don't throw in nonexistent directory on `fnm ls` + run `esy fmt` on codebase (#15)

remotes/origin/add-simple-redirecting-site
Gal Schlezinger 6 years ago committed by GitHub
parent
commit
8cc0e36b37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      executable/Env.re
  2. 4
      executable/FnmApp.re
  3. 15
      executable/ListLocal.re
  4. 6
      feature_tests/list_local_with_nothing_installed/run.sh
  5. 6
      library/Result.re

2
executable/Env.re

@ -9,7 +9,7 @@ let run = isFishShell => {
Console.log( Console.log(
Printf.sprintf("export PATH=%s/bin:$PATH", Directories.currentVersion), Printf.sprintf("export PATH=%s/bin:$PATH", Directories.currentVersion),
); );
} };
Lwt.return(); Lwt.return();
}; };

4
executable/FnmApp.re

@ -91,9 +91,7 @@ let env = {
let isFishShell = { let isFishShell = {
let doc = "Output an env configuration for fish shell."; let doc = "Output an env configuration for fish shell.";
Arg.( Arg.(value & flag & info(["fish"], ~doc));
value & flag & info(["fish"], ~doc)
);
}; };
( (

15
executable/ListLocal.re

@ -1,9 +1,14 @@
open Fnm; open Fnm;
let run = () => exception Cant_read_local_versions;
let main = () =>
Versions.Local.( Versions.Local.(
{ {
let%lwt versions = Versions.getInstalledVersions() |> Result.toLwt; let%lwt versions =
Versions.getInstalledVersions()
|> Result.mapError(_ => Cant_read_local_versions)
|> Result.toLwtErr;
let currentVersion = Versions.getCurrentVersion(); let currentVersion = Versions.getCurrentVersion();
Console.log("The following versions are installed:"); Console.log("The following versions are installed:");
@ -22,3 +27,9 @@ let run = () =>
Lwt.return(); Lwt.return();
} }
); );
let run = () =>
try%lwt (main()) {
| Cant_read_local_versions =>
Console.log("No versions installed!") |> Lwt.return
};

6
feature_tests/list_local_with_nothing_installed/run.sh

@ -0,0 +1,6 @@
#!/bin/bash
set -e
eval $(fnm env)
fnm ls

6
library/Result.re

@ -41,3 +41,9 @@ let toLwt = res =>
| Error(x) => Lwt.fail_with(x) | Error(x) => Lwt.fail_with(x)
| Ok(x) => Lwt.return(x) | Ok(x) => Lwt.return(x)
}; };
let toLwtErr = res =>
switch (res) {
| Error(x) => Lwt.fail(x)
| Ok(x) => Lwt.return(x)
};

Loading…
Cancel
Save