chore(nu): automatically set the node_modules bin dir on cd
When we are moving around the file system I always want to be able to use the locally installed executables from my node modules. Sometimes versions of programs like prettier have different outcomes. I always want to be using the local version rather than the system installed version.
This commit is contained in:
parent
d7a955f103
commit
c482f7a612
2 changed files with 14 additions and 1 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use path.nu
|
||||
use path.nu *
|
||||
|
||||
use fzf.nu *
|
||||
use neovim.nu *
|
||||
|
|
@ -16,6 +16,7 @@ $env.config = {
|
|||
PWD: [
|
||||
{|_, after| nvm dir-hook $after }
|
||||
{|_, after| rvm-dir-hook $after }
|
||||
{|_, after| node-modules-dir-hook $after }
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,3 +6,15 @@ export-env {
|
|||
| prepend ([$env.HOME ".cargo" "bin"] | path join)
|
||||
| str join ":"
|
||||
}
|
||||
|
||||
export def --env node-modules-dir-hook [dir: string] {
|
||||
let nodePath = ([$dir, "node_modules", ".bin"] | path join)
|
||||
if ($nodePath | path exists) {
|
||||
$env.PATH = $env.PATH
|
||||
| split row ":"
|
||||
| where {|x| not ($x | str contains "node_modules")}
|
||||
| prepend $nodePath
|
||||
| str join ":"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue