Skip to content

Commit

Permalink
update fnm script
Browse files Browse the repository at this point in the history
  • Loading branch information
myty committed Sep 11, 2024
1 parent e1fe48e commit 54f13b3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
9 changes: 6 additions & 3 deletions install.nu
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
let host_name = (sys host | get name)
let home_path = if host_name == "Windows" {$env.USERPROFILE} else {$env.HOME}
let home_path = match $nu.os-info.name {
"windows" => $"($env.USERPROFILE)",
_ => $"($env.HOME)",
}

let dotfiles_symlink_path = $"($home_path)/.config/dotfiles"

if (($dotfiles_symlink_path | path exists) != true) {
if host_name == "Windows" {
if $nu.os-info.name == "windows" {
^mklink /d $"($dotfiles_symlink_path)" $"($env.PWD)"
} else {
^ln -s $env.PWD $dotfiles_symlink_path
Expand Down
2 changes: 1 addition & 1 deletion nushell/config.nu
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use "~/.config/dotfiles/nushell/nu_scripts/custom-completions/git/git-completion
use "~/.config/dotfiles/nushell/nu_scripts/custom-completions/npm/npm-completions.nu" *
use "~/.config/dotfiles/nushell/nu_scripts/custom-completions/scoop/scoop-completions.nu" *

use "~/.config/dotfiles/nushell/nu_scripts/modules/fnm/fnm.nu"
source ./modules/fnm/fnm.nu
# Load rbenv
# TODO: Move to ~/.nushellrc for MacOS
Expand Down
23 changes: 23 additions & 0 deletions nushell/modules/fnm/fnm.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
if not (which fnm | is-empty) {
^fnm env --resolve-engines --corepack-enabled --json | from json | load-env

let node_path = match $nu.os-info.name {
"windows" => $"($env.FNM_MULTISHELL_PATH)",
_ => $"($env.FNM_MULTISHELL_PATH)/bin",
}
$env.PATH = ($env.PATH | prepend [ $node_path ])
}

$env.config = ($env.config | merge {
hooks: {
env_change: {
PWD: [{
if ([.nvmrc .node-version] | path exists | any { |it| $it }) {
fnm use
} else {
fnm --log-level=quiet use default
}
}]
}
}
})

0 comments on commit 54f13b3

Please sign in to comment.