Browse Source

Update README for Windows instructions (#271)

remotes/origin/add-with-shims
Gal Schlezinger 4 years ago committed by GitHub
parent
commit
2b89e68d1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 98
      README.md
  2. 2
      docs/fnm.svg
  3. 2
      docs/recorded_screen_script.sh
  4. 2
      src/log_level.rs

98
README.md

@ -12,6 +12,8 @@
## Features ## Features
:earth_americas: Cross-platform support (Mac, Windows, Linux)
:sparkles: Single file, easy installation, instant startup :sparkles: Single file, easy installation, instant startup
:rocket: Built with speed in mind :rocket: Built with speed in mind
@ -22,13 +24,15 @@
### Using a script (MacOS/Linux) ### Using a script (MacOS/Linux)
> :wave: Hey, I'm sorry that the automated way does not support Windows yet. Feel free to contribute it! Maybe [Chocolatey](https://chocolatey.org/) or [Scoop](https://scoop.sh/)?
For `bash`, `zsh` and `fish` shells, there's an [automatic installation script](./.ci/install.sh): For `bash`, `zsh` and `fish` shells, there's an [automatic installation script](./.ci/install.sh):
```bash ```bash
curl -fsSL https://fnm.vercel.app/install | bash curl -fsSL https://fnm.vercel.app/install | bash
``` ```
### Upgrade #### Upgrade
On OSX, it is a simple as `brew upgrade Schniz/tap/fnm`. On OSX, it is a simple as `brew upgrade Schniz/tap/fnm`.
@ -54,7 +58,7 @@ Example:
curl -fsSL https://fnm.vercel.app/install | bash -s -- --install-dir "./.fnm" --skip-shell curl -fsSL https://fnm.vercel.app/install | bash -s -- --install-dir "./.fnm" --skip-shell
``` ```
### Manually ### Manually (OSX/Linux/Windows)
#### Using Homebrew (OSX) #### Using Homebrew (OSX)
@ -66,39 +70,86 @@ brew install Schniz/tap/fnm
Then apply the changes the installer prints, to set up your shell profile. Then apply the changes the installer prints, to set up your shell profile.
#### Using a release binary #### Using a release binary (Linux/Mac/Windows)
- Download the [latest release binary](https://github.com/Schniz/fnm/releases) for your system - Download the [latest release binary](https://github.com/Schniz/fnm/releases) for your system
- Make it available globally on `$PATH` - Make it available globally on `PATH` environment variable
- Add the following line to your `.bashrc`/`.zshrc` file: - Configure your shell profile:
- For **Bash** or **Zsh** users, add the following to your `.bashrc`/`.zshrc` respectively:
```bash ```bash
eval "$(fnm env)" eval "$(fnm env)"
``` ```
If you are using [fish shell](https://fishshell.com/), create `~/.config/fish/conf.d/fnm.fish` add this line to it: - For [**Fish Shell**](https://fishshell.com/) users, create `~/.config/fish/conf.d/fnm.fish` add this line to it:
```fish ```fish
fnm env | source fnm env | source
``` ```
- For **PowerShell** users, add the following to the end of your profile file::
```powershell
fnm env --use-on-cd | Out-String | Invoke-Expression
```
- On Windows, the profile is located at `~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1`
- For Mac/Linux, the profile is located at `~/.config/powershell/Microsoft.PowerShell_profile.ps1`
- For **WinCMD**, aka good old **Windows Command Prompt** or **Batch**, fnm is also supported but is not entirely covered. [You can set up a startup script](https://superuser.com/a/144348) and append the following line:
```
FOR /f "tokens=*" %i IN ('fnm env --use-on-cd') DO CALL %i
```
## Completions ## Completions
- Fish Shell fnm ships its completions with the binary:
[omf-plugin-fnm](https://github.com/james2doyle/omf-plugin-fnm)
```
fnm completions --shell <SHELL>
```
Where `<SHELL>` can be one of the supported shells:
- `bash`
- `zsh`
- `fish`
- `powershell`
Please follow your shell instructions to install them.
## Usage ## Usage
### Global Options
```
fnm [--shell=fish|bash|zsh] [--node-dist-mirror=URI] [--fnm-dir=DIR] [--log-level=quiet|error|info] <command>
```
- Providing `--shell=fish` will output the Fish-compliant version. Omitting it and `fnm` will try to infer the current shell based on the process tree
- Providing `--node-dist-mirror="https://npm.taobao.org/dist"` will use the Chinese mirror of Node.js
- Providing `--fnm-dir="/tmp/fnm"` will install and use versions in `/tmp/fnm` directory
You can always use `fnm --help` to read the docs: You can always use `fnm --help` to read the docs:
### `fnm install [VERSION]` ### `fnm install [VERSION]`
Installs `[VERSION]`. If no version provided, it will install the version specified in the `.node-version` or `.nvmrc` files located in the current working directory. Installs `[VERSION]`. If no version provided, it will install the version specified in the `.node-version` or `.nvmrc` files located in the current working directory.
### `fnm install --lts`
Installs the latest LTS version of Node
### `fnm use [VERSION]` ### `fnm use [VERSION]`
Activates `[VERSION]` as the current Node version. If no version provided, it will activate the version specified in the `.node-version` or `.nvmrc` file located in the current working directory. Activates `[VERSION]` as the current Node version. If no version provided, it will activate the version specified in the `.node-version` or `.nvmrc` file located in the current working directory.
#### Flags
- `--install-if-missing` — installs the version if it isn't installed yet
### `fnm current` ### `fnm current`
Display currently activated Node version. Display currently activated Node version.
@ -123,20 +174,13 @@ Aliases a Node version to a given name.
Aliases a Node version as default. Uses `fnm alias` underneath. Aliases a Node version as default. Uses `fnm alias` underneath.
### `fnm env [--shell=fish|bash|zsh] [--node-dist-mirror=URI] [--use-on-cd] [--fnm-dir=DIR] [--log-level=quiet|error|all]` ### `fnm env`
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 if can't infer the shell. This command is highly influenced by [the global options](#global-options)
- Providing `--shell=fish` will output the Fish-compliant version. Omitting it and `fnm` will try to infer the current shell based on the process tree
- Providing `--node-dist-mirror="https://npm.taobao.org/dist"` will use the Chinese mirror of Node.js
- Providing `--use-on-cd` will also output a script that will automatically change the node version if a `.node-version`/`.nvmrc` file is found
- Providing `--fnm-dir="/tmp/fnm"` will install and use versions in `/tmp/fnm` directory
## Future Plans #### Options:
- [ ] Feature: `fnm use --install` - `--use-on-cd` will also output a script that will automatically change the node version if a `.node-version`/`.nvmrc` file is found
- [ ] Linux: Replace `tar` with a statically linked library too (for ungzip + untar)
- [ ] Windows Support? @ulrikstrid has worked hard to make it compile on Windows, but it will probably need to have different code paths and logic. We can probably make another program and share feature tests with it, instead of relying on Windows for this very-unixy binary.
## Contributing ## Contributing
@ -145,28 +189,20 @@ PRs welcome :tada:
### Developing: ### Developing:
``` ```
npm install -g esy # Install Rust
git clone https://github.com/Schniz/fnm.git git clone https://github.com/Schniz/fnm.git
cd fnm/ cd fnm/
esy install cargo build
esy bootstrap
esy build
``` ```
### Running Binary: ### Running Binary:
After building the project, you can run the main binary that is produced.
``` ```
esy x fnm.exe cargo run -- --help # Will behave like `fnm --help`
``` ```
### Running Tests: ### Running Tests:
``` ```
# Runs some smoke-unity test cargo test
esy test
# Runs the feature tests
feature_tests/run.sh
``` ```

2
docs/fnm.svg

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 30 KiB

2
docs/recorded_screen_script.sh

@ -9,7 +9,7 @@ function type() {
echo $* | pv -qL $[10+(-2 + RANDOM%5)] echo $* | pv -qL $[10+(-2 + RANDOM%5)]
} }
type 'eval `fnm env`' type 'eval "$(fnm env)"'
eval `fnm env` eval `fnm env`
type 'fnm --version' type 'fnm --version'

2
src/log_level.rs

@ -42,7 +42,7 @@ impl std::str::FromStr for LogLevel {
fn from_str(s: &str) -> Result<LogLevel, Self::Err> { fn from_str(s: &str) -> Result<LogLevel, Self::Err> {
match s { match s {
"quiet" => Ok(Self::Quiet), "quiet" => Ok(Self::Quiet),
"info" => Ok(Self::Info), "info" | "all" => Ok(Self::Info),
"error" => Ok(Self::Error), "error" => Ok(Self::Error),
loglevel => Err(format!("I don't know the log level of {:?}", loglevel)), loglevel => Err(format!("I don't know the log level of {:?}", loglevel)),
} }

Loading…
Cancel
Save