Support for ~ (home dir) in path configurations #3756
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.
Summary
This fixes the handling of path that are present in npm configuration (#2930). What's now handled :
~/
(Also~\
on windows) get expandedAll of this is from npm ( https://github.com/npm/npm/blob/latest/lib/config/core.js#L394 ).
I'm not sure that I like the fact that relative paths are relative to cwd instead of the configuration file where they are found but it's what's npm is doing 😉
Motivation
My original motivation was to stop having errors when i'm installing
node-sass
on node 8. As versions ofnode-sass
that aren't the latest don't include pre-built binaries for node 8 the installer try to usenode-gyp
to build a fresh copy.This build would work (I have the necessary dev tools) except that
node-gyp
since recently read thecafile
property and open it. As the cwd for install script is their package, it fail and break most yarn commands.Test plan
I added some unit tests tests.
Also verified on the output of an npm module dumping it's environment in it's install script (during
yarn install --verbose
) :With
.npmrc
: