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. 6
      executable/FnmApp.re
  3. 15
      executable/ListLocal.re
  4. 6
      feature_tests/list_local_with_nothing_installed/run.sh
  5. 2
      library/Http.re
  6. 6
      library/Result.re
  7. 2
      library/Versions.re
  8. 2
      test/SmokeTest.re
  9. 2
      test/TestFnm.re

2
executable/Env.re

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

6
executable/FnmApp.re

@ -91,9 +91,7 @@ let env = { @@ -91,9 +91,7 @@ let env = {
let isFishShell = {
let doc = "Output an env configuration for fish shell.";
Arg.(
value & flag & info(["fish"], ~doc)
);
Arg.(value & flag & info(["fish"], ~doc));
};
(
@ -122,4 +120,4 @@ let defaultCmd = { @@ -122,4 +120,4 @@ let defaultCmd = {
let _ =
Term.eval_choice(defaultCmd, [install, use, listLocal, listRemote, env])
|> Term.exit;
|> Term.exit;

15
executable/ListLocal.re

@ -1,9 +1,14 @@ @@ -1,9 +1,14 @@
open Fnm;
let run = () =>
exception Cant_read_local_versions;
let main = () =>
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();
Console.log("The following versions are installed:");
@ -22,3 +27,9 @@ let run = () => @@ -22,3 +27,9 @@ let run = () =>
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 @@ @@ -0,0 +1,6 @@
#!/bin/bash
set -e
eval $(fnm env)
fnm ls

2
library/Http.re

@ -50,4 +50,4 @@ let download = (url, ~into) => { @@ -50,4 +50,4 @@ let download = (url, ~into) => {
~args=[|url, "-D", "-", "--silent", "-o", into|],
);
response |> parseResponse |> verifyStatus;
};
};

6
library/Result.re

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

2
library/Versions.re

@ -144,4 +144,4 @@ let getRemoteVersions = () => { @@ -144,4 +144,4 @@ let getRemoteVersions = () => {
}
)
|> Lwt.return;
};
};

2
test/SmokeTest.re

@ -14,4 +14,4 @@ describe("Smoke test", ({test}) => { @@ -14,4 +14,4 @@ describe("Smoke test", ({test}) => {
let env = run([|"env"|]) |> redactSfwRoot;
expect.string(env).toMatchSnapshot();
});
});
});

2
test/TestFnm.re

@ -1,3 +1,3 @@ @@ -1,3 +1,3 @@
include SmokeTest;
TestFramework.cli();
TestFramework.cli();

Loading…
Cancel
Save