Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having alias for install and uninstall commands #1277

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gold-onions-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"fnm": patch
---

Having install and uninstall aliases
4 changes: 2 additions & 2 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Usage: fnm [OPTIONS] <COMMAND>
Commands:
list-remote List all remote Node.js versions [aliases: ls-remote]
list List all locally installed Node.js versions [aliases: ls]
install Install a new Node.js version
install Install a new Node.js version [aliases: i]
use Change Node.js version
env Print and set up required environment variables for fnm
completions Print shell completions to stdout
Expand All @@ -17,7 +17,7 @@ Commands:
default Set a version as the default version
current Print the current Node.js version
exec Run a command within fnm context
uninstall Uninstall a Node.js version
uninstall Uninstall a Node.js version [aliases: uni]
help Print this message or the help of the given subcommand(s)

Options:
Expand Down
16 changes: 8 additions & 8 deletions e2e/__snapshots__/uninstall.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

exports[`Bash uninstalls a version: Bash 1`] = `
"set -e
fnm install 12.0.0
fnm i 12.0.0
fnm alias 12.0.0 hello
((fnm ls) | grep v12.0.0 || (echo "Expected output to contain v12.0.0" && exit 1)) | grep hello || (echo "Expected output to contain hello" && exit 1)
fnm uninstall hello
fnm uni hello
if [ "$(fnm ls)" != "* system" ]; then
echo "Expected fnm ls to be * system. Got $(fnm ls)"
exit 1
fi"
`;

exports[`Fish uninstalls a version: Fish 1`] = `
"fnm install 12.0.0
"fnm i 12.0.0
fnm alias 12.0.0 hello
begin; begin; fnm ls; end | grep v12.0.0; or echo "Expected output to contain v12.0.0" && exit 1; end | grep hello; or echo "Expected output to contain hello" && exit 1
fnm uninstall hello
fnm uni hello
set ____test____ (fnm ls)
if test "$____test____" != "* system"
echo "Expected fnm ls to be * system. Got $____test____"
Expand All @@ -26,19 +26,19 @@ end"

exports[`PowerShell uninstalls a version: PowerShell 1`] = `
"$ErrorActionPreference = "Stop"
fnm install 12.0.0
fnm i 12.0.0
fnm alias 12.0.0 hello
$($__out__ = $($($__out__ = $(fnm ls | Select-String v12.0.0); if ($__out__ -eq $null) { exit 1 } else { $__out__ }) | Select-String hello); if ($__out__ -eq $null) { exit 1 } else { $__out__ })
fnm uninstall hello
fnm uni hello
if ( "$(fnm ls)" -ne "* system" ) { echo "Expected fnm ls to be * system. Got $(fnm ls)"; exit 1 }"
`;

exports[`Zsh uninstalls a version: Zsh 1`] = `
"set -e
fnm install 12.0.0
fnm i 12.0.0
fnm alias 12.0.0 hello
((fnm ls) | grep v12.0.0 || (echo "Expected output to contain v12.0.0" && exit 1)) | grep hello || (echo "Expected output to contain hello" && exit 1)
fnm uninstall hello
fnm uni hello
if [ "$(fnm ls)" != "* system" ]; then
echo "Expected fnm ls to be * system. Got $(fnm ls)"
exit 1
Expand Down
4 changes: 2 additions & 2 deletions e2e/uninstall.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ for (const shell of [Bash, Zsh, Fish, PowerShell]) {
describe(shell, () => {
test(`uninstalls a version`, async () => {
await script(shell)
.then(shell.call("fnm", ["install", "12.0.0"]))
.then(shell.call("fnm", ["i", "12.0.0"]))
.then(shell.call("fnm", ["alias", "12.0.0", "hello"]))
.then(
shell.scriptOutputContains(
shell.scriptOutputContains(shell.call("fnm", ["ls"]), "v12.0.0"),
"hello"
)
)
.then(shell.call("fnm", ["uninstall", "hello"]))
.then(shell.call("fnm", ["uni", "hello"]))
.then(
shell.hasCommandOutput(
shell.call("fnm", ["ls"]),
Expand Down
4 changes: 2 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub enum SubCommand {
LsLocal(commands::ls_local::LsLocal),

/// Install a new Node.js version
#[clap(name = "install", bin_name = "install")]
#[clap(name = "install", bin_name = "install", visible_aliases = &["i"])]
Install(commands::install::Install),

/// Change Node.js version
Expand Down Expand Up @@ -67,7 +67,7 @@ pub enum SubCommand {
///
/// > Warning: when providing an alias, it will remove the Node version the alias
/// is pointing to, along with the other aliases that point to the same version.
#[clap(name = "uninstall", bin_name = "uninstall")]
#[clap(name = "uninstall", bin_name = "uninstall", visible_aliases = &["uni"])]
Uninstall(commands::uninstall::Uninstall),
}

Expand Down
Loading