Put local node_modules/.bin in PATH, fixes #22 #25
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.
A lot of back and forth eventually led to this relatively simple fix. By forcing
rackt-cli/node_modules/.bin
to always be inPATH
before executing any of the scripts, you don't have to do any manual work trying to figure out where the binaries are located.This is how it works:
PATH
it constructs, hence the need to manually putnode_modules/.bin
inPATH
. Prior to this fix it worked by manually creating paths to the various binaries innode_modules/.bin
. Now we just reference the binaries indirectly and let the shell figure out where they are by looking inPATH
. Nothing has changed for global installs.node_modules
dir is inPATH
, but since we're not runningbin/rackt
via npm ourselves we manually prependrackt-cli/node_modules/.bin
to path to ensure that the shell looks there first for binaries, before looking in the parent'snode_modules/.bin
. Prior to this fix we did the same thing as above, but since the dependency paths vary based on sibling dependencies we can't reliably create paths without doing a lot of tedious path traversal. Dependency installs now work on both npm 2 and 3.I've tried as best I can to test the various scenarios, but any additional testing would be appreciated. I currently only know of one failing case (which also failed prior to this fix): Referencing
bin/rackt
directly when installed as a dependency will fail, due to the parentnode_modules
missing fromPATH
. Using it vianpm run-script
will of course work.