Browse Source

fix clippy (#1126)

* run cargo clippy --fix

* cargo fmt

* add rust-toolchain.toml

* force rust version

* fixup! run cargo clippy --fix

fix urls

* add clippy and rustfmt

* update command docs

* export Zip on Windows

* remove benchmarking for a while
remotes/origin/use-bnz
Gal Schlezinger 9 months ago committed by GitHub
parent
commit
ced2f306b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 151
      .github/workflows/rust.yml
  2. 52
      docs/commands.md
  3. 3
      rust-toolchain.toml
  4. 4
      src/arch.rs
  5. 4
      src/archive/mod.rs
  6. 2
      src/commands/env.rs
  7. 2
      src/commands/install.rs
  8. 2
      src/commands/use.rs
  9. 4
      src/config.rs
  10. 6
      src/shell/bash.rs
  11. 6
      src/shell/fish.rs
  12. 2
      src/shell/infer/mod.rs
  13. 6
      src/shell/powershell.rs
  14. 6
      src/shell/zsh.rs

151
.github/workflows/rust.yml

@ -10,13 +10,16 @@ concurrency: @@ -10,13 +10,16 @@ concurrency:
group: ci-${{ github.head_ref }}
cancel-in-progress: true
env:
RUST_VERSION: "1.78"
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: stable
rust-version: ${{env.RUST_VERSION}}
- uses: Swatinem/rust-cache@v2
- uses: actions/checkout@v3
- name: cargo fmt
@ -27,7 +30,7 @@ jobs: @@ -27,7 +30,7 @@ jobs:
steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: stable
rust-version: ${{env.RUST_VERSION}}
- uses: Swatinem/rust-cache@v2
- uses: actions/checkout@v3
- name: cargo clippy
@ -41,7 +44,7 @@ jobs: @@ -41,7 +44,7 @@ jobs:
steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: stable
rust-version: ${{env.RUST_VERSION}}
- uses: Swatinem/rust-cache@v2
- uses: actions/checkout@v3
- name: Run tests
@ -53,7 +56,7 @@ jobs: @@ -53,7 +56,7 @@ jobs:
steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: stable
rust-version: ${{env.RUST_VERSION}}
- uses: Swatinem/rust-cache@v2
- uses: actions/checkout@v3
- name: Build release binary
@ -71,7 +74,7 @@ jobs: @@ -71,7 +74,7 @@ jobs:
steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: stable
rust-version: ${{env.RUST_VERSION}}
- uses: Swatinem/rust-cache@v2
- uses: actions/checkout@v3
- name: Build release binary
@ -237,7 +240,7 @@ jobs: @@ -237,7 +240,7 @@ jobs:
steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: stable
rust-version: ${{env.RUST_VERSION}}
targets: x86_64-unknown-linux-musl
- uses: Swatinem/rust-cache@v2
with:
@ -278,7 +281,7 @@ jobs: @@ -278,7 +281,7 @@ jobs:
uses: docker/setup-qemu-action@v2
- uses: hecrj/setup-rust-action@v1
with:
rust-version: stable
rust-version: ${{env.RUST_VERSION}}
- uses: Swatinem/rust-cache@v2
with:
key: arm-binary-${{ matrix.arch }}
@ -358,70 +361,70 @@ jobs: @@ -358,70 +361,70 @@ jobs:
run: |
pnpm run generate-command-docs --check --binary-path=$(which fnm)
run_e2e_benchmarks:
runs-on: ubuntu-latest
name: bench/linux
needs: [build_static_linux_binary]
permissions:
contents: write
pull-requests: write
steps:
- name: install necessary shells
run: sudo apt-get update && sudo apt-get install -y fish zsh bash hyperfine
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: fnm-linux
path: target/release
- name: mark binary as executable
run: chmod +x target/release/fnm
- name: install fnm as binary
run: |
sudo install target/release/fnm /bin
fnm --version
- uses: pnpm/action-setup@v2.2.4
with:
run_install: false
- uses: actions/setup-node@v3
with:
node-version: 18.x
cache: "pnpm"
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- run: pnpm install
- name: Run benchmarks
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SHOULD_STORE: ${{ toJson(!github.event.pull_request) }}
id: benchmark
run: |
delimiter="$(openssl rand -hex 8)"
echo "markdown<<${delimiter}" >> "${GITHUB_OUTPUT}"
node benchmarks/run.mjs --store=$SHOULD_STORE >> "${GITHUB_OUTPUT}"
echo "${delimiter}" >> "${GITHUB_OUTPUT}"
- name: Create a PR comment
if: ${{ github.event.pull_request }}
uses: thollander/actions-comment-pull-request@v2
with:
message: |
## Linux Benchmarks for ${{ github.event.pull_request.head.sha }}
${{ steps.benchmark.outputs.markdown }}
comment_tag: "benchy comment"
- name: Create a commit comment
if: ${{ !github.event.pull_request }}
uses: peter-evans/commit-comment@v2
with:
body: |
## Linux Benchmarks
${{ steps.benchmark.outputs.markdown }}
# TODO: use bnz
# run_e2e_benchmarks:
# runs-on: ubuntu-latest
# name: bench/linux
# needs: [build_static_linux_binary]
# permissions:
# contents: write
# pull-requests: write
# steps:
# - name: install necessary shells
# run: sudo apt-get update && sudo apt-get install -y fish zsh bash hyperfine
# - uses: actions/checkout@v3
# - uses: actions/download-artifact@v3
# with:
# name: fnm-linux
# path: target/release
# - name: mark binary as executable
# run: chmod +x target/release/fnm
# - name: install fnm as binary
# run: |
# sudo install target/release/fnm /bin
# fnm --version
# - uses: pnpm/action-setup@v2.2.4
# with:
# run_install: false
# - uses: actions/setup-node@v3
# with:
# node-version: 18.x
# cache: "pnpm"
# - name: Get pnpm store directory
# id: pnpm-cache
# run: |
# echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
# - uses: actions/cache@v3
# name: Setup pnpm cache
# with:
# path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
# key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
# restore-keys: |
# ${{ runner.os }}-pnpm-store-
# - run: pnpm install
# - name: Run benchmarks
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SHOULD_STORE: ${{ toJson(!github.event.pull_request) }}
# id: benchmark
# run: |
# delimiter="$(openssl rand -hex 8)"
# echo "markdown<<${delimiter}" >> "${GITHUB_OUTPUT}"
# node benchmarks/run.mjs --store=$SHOULD_STORE >> "${GITHUB_OUTPUT}"
# echo "${delimiter}" >> "${GITHUB_OUTPUT}"
# - name: Create a PR comment
# if: ${{ github.event.pull_request }}
# uses: thollander/actions-comment-pull-request@v2
# with:
# message: |
# ## Linux Benchmarks for ${{ github.event.pull_request.head.sha }}
# ${{ steps.benchmark.outputs.markdown }}
# comment_tag: "benchy comment"
#
# - name: Create a commit comment
# if: ${{ !github.event.pull_request }}
# uses: peter-evans/commit-comment@v2
# with:
# body: |
# ## Linux Benchmarks
# ${{ steps.benchmark.outputs.markdown }}

52
docs/commands.md

@ -22,7 +22,7 @@ Commands: @@ -22,7 +22,7 @@ Commands:
Options:
--node-dist-mirror <NODE_DIST_MIRROR>
https://nodejs.org/dist/ mirror
<https://nodejs.org/dist/> mirror
[env: FNM_NODE_DIST_MIRROR]
[default: https://nodejs.org/dist]
@ -55,7 +55,7 @@ Options: @@ -55,7 +55,7 @@ Options:
- recursive: Use the version of Node defined within the current directory and all parent directories
--corepack-enabled
Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see https://nodejs.org/api/corepack.html
Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>
[env: FNM_COREPACK_ENABLED]
@ -82,7 +82,7 @@ Usage: fnm list-remote [OPTIONS] @@ -82,7 +82,7 @@ Usage: fnm list-remote [OPTIONS]
Options:
--node-dist-mirror <NODE_DIST_MIRROR>
https://nodejs.org/dist/ mirror
<https://nodejs.org/dist/> mirror
[env: FNM_NODE_DIST_MIRROR]
[default: https://nodejs.org/dist]
@ -115,7 +115,7 @@ Options: @@ -115,7 +115,7 @@ Options:
- recursive: Use the version of Node defined within the current directory and all parent directories
--corepack-enabled
Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see https://nodejs.org/api/corepack.html
Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>
[env: FNM_COREPACK_ENABLED]
@ -139,7 +139,7 @@ Usage: fnm list [OPTIONS] @@ -139,7 +139,7 @@ Usage: fnm list [OPTIONS]
Options:
--node-dist-mirror <NODE_DIST_MIRROR>
https://nodejs.org/dist/ mirror
<https://nodejs.org/dist/> mirror
[env: FNM_NODE_DIST_MIRROR]
[default: https://nodejs.org/dist]
@ -172,7 +172,7 @@ Options: @@ -172,7 +172,7 @@ Options:
- recursive: Use the version of Node defined within the current directory and all parent directories
--corepack-enabled
Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see https://nodejs.org/api/corepack.html
Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>
[env: FNM_COREPACK_ENABLED]
@ -203,7 +203,7 @@ Options: @@ -203,7 +203,7 @@ Options:
Install latest LTS
--node-dist-mirror <NODE_DIST_MIRROR>
https://nodejs.org/dist/ mirror
<https://nodejs.org/dist/> mirror
[env: FNM_NODE_DIST_MIRROR]
[default: https://nodejs.org/dist]
@ -242,7 +242,7 @@ Options: @@ -242,7 +242,7 @@ Options:
- recursive: Use the version of Node defined within the current directory and all parent directories
--corepack-enabled
Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see https://nodejs.org/api/corepack.html
Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>
[env: FNM_COREPACK_ENABLED]
@ -273,7 +273,7 @@ Options: @@ -273,7 +273,7 @@ Options:
Install the version if it isn't installed yet
--node-dist-mirror <NODE_DIST_MIRROR>
https://nodejs.org/dist/ mirror
<https://nodejs.org/dist/> mirror
[env: FNM_NODE_DIST_MIRROR]
[default: https://nodejs.org/dist]
@ -309,7 +309,7 @@ Options: @@ -309,7 +309,7 @@ Options:
- recursive: Use the version of Node defined within the current directory and all parent directories
--corepack-enabled
Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see https://nodejs.org/api/corepack.html
Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>
[env: FNM_COREPACK_ENABLED]
@ -337,7 +337,7 @@ Usage: fnm env [OPTIONS] @@ -337,7 +337,7 @@ Usage: fnm env [OPTIONS]
Options:
--node-dist-mirror <NODE_DIST_MIRROR>
https://nodejs.org/dist/ mirror
<https://nodejs.org/dist/> mirror
[env: FNM_NODE_DIST_MIRROR]
[default: https://nodejs.org/dist]
@ -381,7 +381,7 @@ Options: @@ -381,7 +381,7 @@ Options:
- recursive: Use the version of Node defined within the current directory and all parent directories
--corepack-enabled
Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see https://nodejs.org/api/corepack.html
Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>
[env: FNM_COREPACK_ENABLED]
@ -405,7 +405,7 @@ Usage: fnm completions [OPTIONS] @@ -405,7 +405,7 @@ Usage: fnm completions [OPTIONS]
Options:
--node-dist-mirror <NODE_DIST_MIRROR>
https://nodejs.org/dist/ mirror
<https://nodejs.org/dist/> mirror
[env: FNM_NODE_DIST_MIRROR]
[default: https://nodejs.org/dist]
@ -443,7 +443,7 @@ Options: @@ -443,7 +443,7 @@ Options:
- recursive: Use the version of Node defined within the current directory and all parent directories
--corepack-enabled
Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see https://nodejs.org/api/corepack.html
Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>
[env: FNM_COREPACK_ENABLED]
@ -474,7 +474,7 @@ Arguments: @@ -474,7 +474,7 @@ Arguments:
Options:
--node-dist-mirror <NODE_DIST_MIRROR>
https://nodejs.org/dist/ mirror
<https://nodejs.org/dist/> mirror
[env: FNM_NODE_DIST_MIRROR]
[default: https://nodejs.org/dist]
@ -507,7 +507,7 @@ Options: @@ -507,7 +507,7 @@ Options:
- recursive: Use the version of Node defined within the current directory and all parent directories
--corepack-enabled
Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see https://nodejs.org/api/corepack.html
Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>
[env: FNM_COREPACK_ENABLED]
@ -535,7 +535,7 @@ Arguments: @@ -535,7 +535,7 @@ Arguments:
Options:
--node-dist-mirror <NODE_DIST_MIRROR>
https://nodejs.org/dist/ mirror
<https://nodejs.org/dist/> mirror
[env: FNM_NODE_DIST_MIRROR]
[default: https://nodejs.org/dist]
@ -568,7 +568,7 @@ Options: @@ -568,7 +568,7 @@ Options:
- recursive: Use the version of Node defined within the current directory and all parent directories
--corepack-enabled
Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see https://nodejs.org/api/corepack.html
Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>
[env: FNM_COREPACK_ENABLED]
@ -598,7 +598,7 @@ Arguments: @@ -598,7 +598,7 @@ Arguments:
Options:
--node-dist-mirror <NODE_DIST_MIRROR>
https://nodejs.org/dist/ mirror
<https://nodejs.org/dist/> mirror
[env: FNM_NODE_DIST_MIRROR]
[default: https://nodejs.org/dist]
@ -631,7 +631,7 @@ Options: @@ -631,7 +631,7 @@ Options:
- recursive: Use the version of Node defined within the current directory and all parent directories
--corepack-enabled
Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see https://nodejs.org/api/corepack.html
Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>
[env: FNM_COREPACK_ENABLED]
@ -655,7 +655,7 @@ Usage: fnm current [OPTIONS] @@ -655,7 +655,7 @@ Usage: fnm current [OPTIONS]
Options:
--node-dist-mirror <NODE_DIST_MIRROR>
https://nodejs.org/dist/ mirror
<https://nodejs.org/dist/> mirror
[env: FNM_NODE_DIST_MIRROR]
[default: https://nodejs.org/dist]
@ -688,7 +688,7 @@ Options: @@ -688,7 +688,7 @@ Options:
- recursive: Use the version of Node defined within the current directory and all parent directories
--corepack-enabled
Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see https://nodejs.org/api/corepack.html
Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>
[env: FNM_COREPACK_ENABLED]
@ -721,7 +721,7 @@ Arguments: @@ -721,7 +721,7 @@ Arguments:
Options:
--node-dist-mirror <NODE_DIST_MIRROR>
https://nodejs.org/dist/ mirror
<https://nodejs.org/dist/> mirror
[env: FNM_NODE_DIST_MIRROR]
[default: https://nodejs.org/dist]
@ -757,7 +757,7 @@ Options: @@ -757,7 +757,7 @@ Options:
- recursive: Use the version of Node defined within the current directory and all parent directories
--corepack-enabled
Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see https://nodejs.org/api/corepack.html
Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>
[env: FNM_COREPACK_ENABLED]
@ -787,7 +787,7 @@ Arguments: @@ -787,7 +787,7 @@ Arguments:
Options:
--node-dist-mirror <NODE_DIST_MIRROR>
https://nodejs.org/dist/ mirror
<https://nodejs.org/dist/> mirror
[env: FNM_NODE_DIST_MIRROR]
[default: https://nodejs.org/dist]
@ -820,7 +820,7 @@ Options: @@ -820,7 +820,7 @@ Options:
- recursive: Use the version of Node defined within the current directory and all parent directories
--corepack-enabled
Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see https://nodejs.org/api/corepack.html
Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>
[env: FNM_COREPACK_ENABLED]

3
rust-toolchain.toml

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
[toolchain]
channel = "1.78"
components = ["rustfmt", "clippy"]

4
src/arch.rs

@ -17,10 +17,10 @@ pub enum Arch { @@ -17,10 +17,10 @@ pub enum Arch {
pub fn get_safe_arch<'a>(arch: &'a Arch, version: &Version) -> &'a Arch {
use crate::system_info::{platform_arch, platform_name};
return match (platform_name(), platform_arch(), version) {
match (platform_name(), platform_arch(), version) {
("darwin", "arm64", Version::Semver(v)) if v.major < 16 => &Arch::X64,
_ => arch,
};
}
}
#[cfg(windows)]

4
src/archive/mod.rs

@ -3,5 +3,9 @@ pub mod tar_xz; @@ -3,5 +3,9 @@ pub mod tar_xz;
pub mod zip;
pub use self::extract::{Error, Extract};
#[cfg(unix)]
pub use self::tar_xz::TarXz;
#[cfg(windows)]
pub use self::zip::Zip;

2
src/commands/env.rs

@ -44,7 +44,7 @@ fn make_symlink(config: &FnmConfig) -> Result<std::path::PathBuf, Error> { @@ -44,7 +44,7 @@ fn make_symlink(config: &FnmConfig) -> Result<std::path::PathBuf, Error> {
}
match symlink_dir(config.default_version_dir(), &temp_dir) {
Ok(_) => Ok(temp_dir),
Ok(()) => Ok(temp_dir),
Err(source) => Err(Error::CantCreateSymlink { source, temp_dir }),
}
}

2
src/commands/install.rs

@ -147,7 +147,7 @@ impl Command for Install { @@ -147,7 +147,7 @@ impl Command for Install {
outln!(config, Error, "{} {}", "warning:".bold().yellow(), err);
}
Err(source) => Err(Error::DownloadError { source })?,
Ok(_) => {}
Ok(()) => {}
};
if config.corepack_enabled() {

2
src/commands/use.rs

@ -153,7 +153,7 @@ fn install_new_version( @@ -153,7 +153,7 @@ fn install_new_version(
fn replace_symlink(from: &std::path::Path, to: &std::path::Path) -> std::io::Result<()> {
let symlink_deletion_result = fs::remove_symlink_dir(to);
match fs::symlink_dir(from, to) {
ok @ Ok(_) => ok,
ok @ Ok(()) => ok,
err @ Err(_) => symlink_deletion_result.and(err),
}
}

4
src/config.rs

@ -7,7 +7,7 @@ use url::Url; @@ -7,7 +7,7 @@ use url::Url;
#[derive(clap::Parser, Debug)]
pub struct FnmConfig {
/// https://nodejs.org/dist/ mirror
/// <https://nodejs.org/dist/> mirror
#[clap(
long,
env = "FNM_NODE_DIST_MIRROR",
@ -67,7 +67,7 @@ pub struct FnmConfig { @@ -67,7 +67,7 @@ pub struct FnmConfig {
/// Enable corepack support for each new installation.
/// This will make fnm call `corepack enable` on every Node.js installation.
/// For more information about corepack see https://nodejs.org/api/corepack.html
/// For more information about corepack see <https://nodejs.org/api/corepack.html>
#[clap(
long,
env = "FNM_COREPACK_ENABLED",

6
src/shell/bash.rs

@ -28,13 +28,13 @@ impl Shell for Bash { @@ -28,13 +28,13 @@ impl Shell for Bash {
fn use_on_cd(&self, config: &crate::config::FnmConfig) -> anyhow::Result<String> {
let autoload_hook = match config.version_file_strategy() {
VersionFileStrategy::Local => indoc!(
r#"
r"
if [[ -f .node-version || -f .nvmrc ]]; then
fnm use --silent-if-unchanged
fi
"#
"
),
VersionFileStrategy::Recursive => r#"fnm use --silent-if-unchanged"#,
VersionFileStrategy::Recursive => r"fnm use --silent-if-unchanged",
};
Ok(formatdoc!(
r#"

6
src/shell/fish.rs

@ -28,13 +28,13 @@ impl Shell for Fish { @@ -28,13 +28,13 @@ impl Shell for Fish {
fn use_on_cd(&self, config: &crate::config::FnmConfig) -> anyhow::Result<String> {
let autoload_hook = match config.version_file_strategy() {
VersionFileStrategy::Local => indoc!(
r#"
r"
if test -f .node-version -o -f .nvmrc
fnm use --silent-if-unchanged
end
"#
"
),
VersionFileStrategy::Recursive => r#"fnm use --silent-if-unchanged"#,
VersionFileStrategy::Recursive => r"fnm use --silent-if-unchanged",
};
Ok(formatdoc!(
r#"

2
src/shell/infer/mod.rs

@ -7,7 +7,7 @@ pub use self::unix::infer_shell; @@ -7,7 +7,7 @@ pub use self::unix::infer_shell;
#[cfg(not(unix))]
pub use self::windows::infer_shell;
pub(self) fn shell_from_string(shell: &str) -> Option<Box<dyn super::Shell>> {
fn shell_from_string(shell: &str) -> Option<Box<dyn super::Shell>> {
use super::{Bash, Fish, PowerShell, WindowsCmd, Zsh};
match shell {
"sh" | "bash" => return Some(Box::from(Bash)),

6
src/shell/powershell.rs

@ -28,11 +28,11 @@ impl Shell for PowerShell { @@ -28,11 +28,11 @@ impl Shell for PowerShell {
fn use_on_cd(&self, config: &crate::config::FnmConfig) -> anyhow::Result<String> {
let autoload_hook = match config.version_file_strategy() {
VersionFileStrategy::Local => indoc!(
r#"
r"
If ((Test-Path .nvmrc) -Or (Test-Path .node-version)) { & fnm use --silent-if-unchanged }
"#
"
),
VersionFileStrategy::Recursive => r#"fnm use --silent-if-unchanged"#,
VersionFileStrategy::Recursive => r"fnm use --silent-if-unchanged",
};
Ok(formatdoc!(
r#"

6
src/shell/zsh.rs

@ -32,13 +32,13 @@ impl Shell for Zsh { @@ -32,13 +32,13 @@ impl Shell for Zsh {
fn use_on_cd(&self, config: &crate::config::FnmConfig) -> anyhow::Result<String> {
let autoload_hook = match config.version_file_strategy() {
VersionFileStrategy::Local => indoc!(
r#"
r"
if [[ -f .node-version || -f .nvmrc ]]; then
fnm use --silent-if-unchanged
fi
"#
"
),
VersionFileStrategy::Recursive => r#"fnm use --silent-if-unchanged"#,
VersionFileStrategy::Recursive => r"fnm use --silent-if-unchanged",
};
Ok(formatdoc!(
r#"

Loading…
Cancel
Save