From edc4b4d0d01037ff4d4eee0cb425941b792b33ae Mon Sep 17 00:00:00 2001 From: Xanadu Zhang <3369760+yeahnoob@users.noreply.github.com> Date: Mon, 6 Dec 2021 17:29:02 +0800 Subject: [PATCH] auto-checking the latest version when install CLI `rg` can be replace by `grep` or other pattern search tool. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 94599b7..4752538 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,10 @@ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash ```sh wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash ``` +```sh +NVM_LATEST_VERSION=$(curl --silent "https://api.github.com/repos/nvm-sh/nvm/releases/latest" | rg -e '"tag_name":\s"(.*)".*' -r '$1') +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_LATEST_VERSION}/install.sh | bash +``` Running either of the above commands downloads a script and runs it. The script clones the nvm repository to `~/.nvm`, and attempts to add the source lines from the snippet below to the correct profile file (`~/.bash_profile`, `~/.zshrc`, `~/.profile`, or `~/.bashrc`).