fix: handle npm prefix config environment variables - #7070
Merged
Merged
Conversation
arcanis
requested changes
Feb 28, 2019
| key = key.replace(/__/g, '.'); | ||
|
|
||
| // replace underscores with dashes | ||
| key = key.replace(/_/g, '-'); |
Member
There was a problem hiding this comment.
Can you instead add it in a more generic way that supports __?
For example: key.replace(/([^_])_/g, '$1-')
Contributor
Author
There was a problem hiding this comment.
That's a good idea. We're probably assuming any key starting with an underscore needs to stay an underscore, but that's probably always true
# Conflicts: # CHANGELOG.md
NicholasBoll
commented
Feb 28, 2019
| test('correctly escapes environment config variables', () => { | ||
| const testCwd = '.'; | ||
| const {mockRequestManager, mockRegistries, mockReporter} = createMocks(); | ||
| const npmRegistry = new NpmRegistry(testCwd, mockRegistries, mockRequestManager, mockReporter, true, []); |
Contributor
Author
There was a problem hiding this comment.
I had trouble figuring out where these tests should go. mergeEnv is an instance method that requires a whole mocked registry to test.
Simplifying this test would involve refactoring the mergeEnv method to use a utility method, but I decided to reduce the changes to the code and instead have a more complicated test
Member
|
Yep! Thanks 😃 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #4682
Summary
Passing
npm_config_environment variables changed all underscores (_) to dashes (-) which isn't correct behavior for special config variables (_auth,_authToken,_usernameand_password). An additional check was added tobase-registry.jsto filter out these config keys from this processing.Test plan
yarn test- all tests passed except two tests that have nothing with my change - they are integration tests (I assume my environment isn't set up correctly for these to pass? Maybe CI will verify?)