Fix calling node/nodejs binary in nodejs_version
#1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The primary nodejs executable being called
nodejs
is a Debian-ism, and is not compatible with upstream nodejs and non-Debian distros, because upstream just calls the binarynode
.This makes the
node_version
which callsnodejs --version
method fail on non-Debian systems, wherenodejs
is actually callednode
instead.Instead of just executing the
nodejs
command, we now first search for it inPATH
, usingdistutils.spawn.find_executable
, which should be available on Python 2.4+. (see also: http://stackoverflow.com/a/12611523)When no node executable is found, a NodeBinaryNotFoundError is now raised.
If one of the node executables is found, we return the result of
node/nodejs --version
as before.Edit: to clarify: the reasoning behind Debian not calling node
node
, is that/usr/bin/node
is actually in use by a package that pre-exists nodejs (ax25-node
). Since the search fornodejs
is before the search fornode
, this should not give any problems for users that have both installed. There might be a false positive whenax25-node
is installed, but nodejs is not, but I think we can assume here npm users have nodejs installed already anyway ;)