Skip to content

Commit e868dbe

Browse files
authored
Replace additional use of which(1) with shutil.which() (#355)
Replace the remaining use of external `which(1)` tool with `shutil.which()` from the standard Python library, finally removing the dependency on a third party package. This is a followup to 1024f4f.
1 parent 37c0c30 commit e868dbe

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

nodeenv.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -934,14 +934,10 @@ def install_activate(env_dir, args):
934934
prompt = args.prompt or '(%s)' % os.path.basename(os.path.abspath(env_dir))
935935

936936
if args.node == "system":
937-
env = os.environ.copy()
938-
env.update({'PATH': remove_env_bin_from_path(env['PATH'], bin_dir)})
937+
path_var = remove_env_bin_from_path(os.environ['PATH'], bin_dir)
939938
for candidate in ("nodejs", "node"):
940-
which_node_output, _ = subprocess.Popen(
941-
["which", candidate],
942-
stdout=subprocess.PIPE, env=env).communicate()
943-
shim_node = clear_output(which_node_output)
944-
if shim_node:
939+
shim_node = shutil.which(candidate, path=path_var)
940+
if shim_node is not None:
945941
break
946942
assert shim_node, "Did not find nodejs or node system executable"
947943

0 commit comments

Comments
 (0)