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. 110
      README.md
  2. 2
      docs/fnm.svg
  3. 2
      docs/recorded_screen_script.sh
  4. 2
      src/log_level.rs

110
README.md

@ -12,6 +12,8 @@ @@ -12,6 +12,8 @@
## Features
:earth_americas: Cross-platform support (Mac, Windows, Linux)
:sparkles: Single file, easy installation, instant startup
:rocket: Built with speed in mind
@ -22,13 +24,15 @@ @@ -22,13 +24,15 @@
### 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):
```bash
curl -fsSL https://fnm.vercel.app/install | bash
```
### Upgrade
#### Upgrade
On OSX, it is a simple as `brew upgrade Schniz/tap/fnm`.
@ -54,7 +58,7 @@ Example: @@ -54,7 +58,7 @@ Example:
curl -fsSL https://fnm.vercel.app/install | bash -s -- --install-dir "./.fnm" --skip-shell
```
### Manually
### Manually (OSX/Linux/Windows)
#### Using Homebrew (OSX)
@ -66,39 +70,86 @@ brew install Schniz/tap/fnm @@ -66,39 +70,86 @@ brew install Schniz/tap/fnm
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
- Make it available globally on `$PATH`
- Add the following line to your `.bashrc`/`.zshrc` file:
- Make it available globally on `PATH` environment variable
- Configure your shell profile:
- For **Bash** or **Zsh** users, add the following to your `.bashrc`/`.zshrc` respectively:
```bash
eval "$(fnm env)"
```
- For [**Fish Shell**](https://fishshell.com/) users, create `~/.config/fish/conf.d/fnm.fish` add this line to it:
```fish
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
```
```bash
eval "$(fnm env)"
```
- 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`
If you are using [fish shell](https://fishshell.com/), create `~/.config/fish/conf.d/fnm.fish` add this line to it:
- 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:
```fish
fnm env | source
```
```
FOR /f "tokens=*" %i IN ('fnm env --use-on-cd') DO CALL %i
```
## Completions
- Fish Shell
[omf-plugin-fnm](https://github.com/james2doyle/omf-plugin-fnm)
fnm ships its completions with the binary:
```
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
### 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:
### `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.
### `fnm install --lts`
Installs the latest LTS version of Node
### `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.
#### Flags
- `--install-if-missing` — installs the version if it isn't installed yet
### `fnm current`
Display currently activated Node version.
@ -123,20 +174,13 @@ Aliases a Node version to a given name. @@ -123,20 +174,13 @@ Aliases a Node version to a given name.
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.
- 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
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)
## Future Plans
#### Options:
- [ ] Feature: `fnm use --install`
- [ ] 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.
- `--use-on-cd` will also output a script that will automatically change the node version if a `.node-version`/`.nvmrc` file is found
## Contributing
@ -145,28 +189,20 @@ PRs welcome :tada: @@ -145,28 +189,20 @@ PRs welcome :tada:
### Developing:
```
npm install -g esy
# Install Rust
git clone https://github.com/Schniz/fnm.git
cd fnm/
esy install
esy bootstrap
esy build
cargo build
```
### 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:
```
# Runs some smoke-unity test
esy test
# Runs the feature tests
feature_tests/run.sh
cargo test
```

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

2
src/log_level.rs

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

Loading…
Cancel
Save