Use separator for activation script result #2552
Merged
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.
Motivation
Closes #2370
Some users seem to have issues with their shells printing extra output when being invoked by NodeJS. This leads to an invalid JSON being returned by the activation script, which we fail to parse.
I believe we can make the activation more robust if we just print the activated JSON between two separators so that we can automatically ignore any extra output.
Implementation
I noticed that, with the exception of
chruby
, all activation scripts are almost identical. So I extract a good part of the logic to the parent class, so that we can more easily share with all manager integrations.Then I started printing the environment between two separators and we look for those before parsing the result.
Automated Tests
Had to updated the stubs on all tests to match the new behaviour.
Manual Tests
Since version manager integrations are always critical, I would like to make a preview release to verify if everything is fixed and works as expected after this PR is approved, but before shipping.