Skip to content

Commit

Permalink
Export has_run to child processes, cleanup (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
FabioAntunes authored Oct 20, 2018
1 parent 0830e3c commit 3c843fd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
7 changes: 0 additions & 7 deletions functions/__can_run_command.fish

This file was deleted.

17 changes: 12 additions & 5 deletions functions/__nvm_run.fish
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,26 @@ function __nvm_run
end
end

function can_run_command
if type -P $argv[1] > /dev/null 2>&1; or type -P node > /dev/null 2>&1
return
else
return 1
end
end

function run_default
nvm use default > /dev/null
set -g NVM_HAS_RUN 1
if __can_run_command $argv[1]
set -gx NVM_HAS_RUN 1
if can_run_command $argv[1]
run_command $argv
end
end

if not test -n "$NVM_HAS_RUN"
if test -f .nvmrc; and nvm use > /dev/null 2>&1

if __can_run_command $argv[1]
set -g NVM_HAS_RUN 1
if can_run_command $argv[1]
set -gx NVM_HAS_RUN 1
run_command $argv
else
run_default $argv
Expand Down
3 changes: 1 addition & 2 deletions functions/nvm_alias_command.fish
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ function nvm_alias_command -d "Create an alias command"
if test $val != "nvm.fish";
and test $val != "nvm_alias_command.fish";
and test $val != "nvm_alias_function.fish";
and test $val != "__nvm_run.fish";
and test $val != "__can_run_command.fish"
and test $val != "__nvm_run.fish"

set -l alias (string replace .fish '' $val)
__create_alias_command "$outputPath/$alias" $alias
Expand Down

0 comments on commit 3c843fd

Please sign in to comment.