Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

Commit

Permalink
fix: use parent shell path in place of node process path (#488)
Browse files Browse the repository at this point in the history
* fix: use parent shell path and not node process path

* chore: add missing peer deps

* wip: add sh user paths from fish shell

* chore: undo extras

* refactor: ugly
  • Loading branch information
iamogbz authored Nov 12, 2019
1 parent 2bc3e1f commit f83d5a8
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/shell/yvm.fish
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ function yvm
end

function yvm_call_node_script
set -lx sh_user_paths (string join ':' $PATH)
set -lx fish_user_paths $fish_user_paths
node "$YVM_DIR/yvm.js" $argv
end
Expand Down
1 change: 1 addition & 0 deletions src/shell/yvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ yvm() {

yvm_call_node_script() {
# do not add anything that outputs stuff to stdout in function, its output is stored in a variable
export sh_user_paths=$PATH
node "${YVM_DIR}/yvm.js" $@
}

Expand Down
2 changes: 1 addition & 1 deletion src/util/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const getCurrentPath = shell => {
if (isFishShell(shell)) {
return process.env.fish_user_paths || ''
}
return process.env.PATH || ''
return process.env.sh_user_paths || process.env.PATH || ''
}

export const yvmPath = process.env.YVM_DIR || path.resolve(os.homedir(), '.yvm')
Expand Down
2 changes: 1 addition & 1 deletion test/util/path.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('util.path', () => {
const mockSystemPaths = ['/path/one', '/some/other/path', '/some/new/path']
const mockPathEntries = [mockShimPath, mockVersionPath, ...mockSystemPaths]

jest.spyOnProp(process.env, 'PATH').mockValue(
jest.spyOnProp(process.env, 'sh_user_paths').mockValue(
toPathString({
paths: mockPathEntries,
}),
Expand Down

0 comments on commit f83d5a8

Please sign in to comment.