Browse Source

Add `default`, as a shortcut for `alias default` (#106)

A higher-level way to set the default Node version, instead of managing that using pure aliases.
remotes/origin/add-simple-redirecting-site
Dennis Dang 6 years ago committed by Gal Schlezinger
parent
commit
430541a16a
  1. 8
      README.md
  2. 31
      executable/FnmApp.re
  3. 2
      feature_tests/aliases/run.sh

8
README.md

@ -88,6 +88,14 @@ Lists the installed Node versions.
Lists the Node versions available to download remotely. Lists the Node versions available to download remotely.
### `fnm alias [VERSION] [NAME]`
Aliases a Node version to a given name.
### `fnm default [VERSION]`
Aliases a Node version as default. Uses `fnm alias` underneath.
### `fnm env [--multi] [--shell=fish|bash|zsh] [--node-dist-mirror=URI] [--use-on-cd] [--base-dir=DIR] [--log-level=quiet|error|all]` ### `fnm env [--multi] [--shell=fish|bash|zsh] [--node-dist-mirror=URI] [--use-on-cd] [--base-dir=DIR] [--log-level=quiet|error|all]`
Prints the required shell commands in order to configure your shell, Bash compliant by default. Prints the required shell commands in order to configure your shell, Bash compliant by default.

31
executable/FnmApp.re

@ -3,6 +3,8 @@ let version = Fnm.Fnm__Package.version;
module Commands = { module Commands = {
let use = (version, quiet) => Lwt_main.run(Use.run(~version, ~quiet)); let use = (version, quiet) => Lwt_main.run(Use.run(~version, ~quiet));
let alias = (version, name) => Lwt_main.run(Alias.run(~name, ~version)); let alias = (version, name) => Lwt_main.run(Alias.run(~name, ~version));
let default = version =>
Lwt_main.run(Alias.run(~name="default", ~version));
let listRemote = () => Lwt_main.run(ListRemote.run()); let listRemote = () => Lwt_main.run(ListRemote.run());
let listLocal = () => Lwt_main.run(ListLocal.run()); let listLocal = () => Lwt_main.run(ListLocal.run());
let install = version => Lwt_main.run(Install.run(~version)); let install = version => Lwt_main.run(Install.run(~version));
@ -170,6 +172,33 @@ let alias = {
); );
}; };
let default = {
let doc = "Alias a version as default";
let man = [];
let sdocs = Manpage.s_common_options;
let selectedVersion = {
let doc = "The version to be aliased as default";
Arg.(
required
& pos(0, some(string), None)
& info([], ~docv="VERSION", ~doc)
);
};
(
Term.(const(Commands.default) $ selectedVersion),
Term.info(
"default",
~version,
~doc,
~exits=Term.default_exits,
~man,
~sdocs,
),
);
};
let env = { let env = {
let doc = "Show env configurations"; let doc = "Show env configurations";
let sdocs = Manpage.s_common_options; let sdocs = Manpage.s_common_options;
@ -270,6 +299,6 @@ let defaultCmd = {
let _ = let _ =
Term.eval_choice( Term.eval_choice(
defaultCmd, defaultCmd,
[install, uninstall, use, alias, listLocal, listRemote, env], [install, uninstall, use, alias, default, listLocal, listRemote, env],
) )
|> Term.exit; |> Term.exit;

2
feature_tests/aliases/run.sh

@ -7,8 +7,10 @@ fnm install 8.11.3
fnm alias 8.11.3 oldie fnm alias 8.11.3 oldie
fnm alias 6.11.3 older fnm alias 6.11.3 older
fnm default 6.11.3
VERSIONS_INSTALLED=$(fnm ls) VERSIONS_INSTALLED=$(fnm ls)
echo "$VERSIONS_INSTALLED" | grep 8.11.3 | grep oldie echo "$VERSIONS_INSTALLED" | grep 8.11.3 | grep oldie
echo "$VERSIONS_INSTALLED" | grep 6.11.3 | grep older echo "$VERSIONS_INSTALLED" | grep 6.11.3 | grep older
echo "$VERSIONS_INSTALLED" | grep 6.11.3 | grep default

Loading…
Cancel
Save