Support Darwin bash in bin/yarn (#6568)

* Support Darwin bash in bin/yarn

If the yarn binary is a symlink the `basepath` is not correctly resolved on OSX/Darwin.

For example take the following structure:
```
vendor/yarnpkg/yarn
vendor/bin/yarn -> ../yarnpkg/yarn/bin/yarn
```

And run yarn:
```
$ yarn
internal/modules/cjs/loader.js:582
    throw err;
    ^

Error: Cannot find module '/Users/yarnpkg/yarn/bin/yarn.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
    at Function.Module._load (internal/modules/cjs/loader.js:506:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
    at startup (internal/bootstrap/node.js:285:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
```
Since the symlink is not resolved the relative path in the symlink leads to the wrong path.

This PR, fixes that issue.

* Update CHANGELOG.md
This commit is contained in:
Hidde Boomsma
2018-10-23 16:11:15 +02:00
committed by Maël Nison
parent f6d0a5b85a
commit af72e6a1f7
2 changed files with 5 additions and 0 deletions

View File

@@ -40,6 +40,10 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa
[#6562](https://github.com/yarnpkg/yarn/pull/6562) - [**Bertrand Marron**](https://github.com/tusbar)
- Fixes Yarn invocations on Darwin when the `yarn` binary was symlinked
[#6568](https://github.com/yarnpkg/yarn/pull/6568) - [**Hidde Boomsma**](https://github.com/hboomsma)
- Fixes `require.resolve` when used together with the `paths` option
[#6565](https://github.com/yarnpkg/yarn/pull/6565) - [**Maël Nison**](https://twitter.com/arcanis)

View File

@@ -3,6 +3,7 @@ argv0=$(echo "$0" | sed -e 's,\\,/,g')
basedir=$(dirname "$(readlink "$0" || echo "$argv0")")
case "$(uname -s)" in
Darwin) basedir="$( cd "$( dirname "$argv0" )" && pwd )";;
Linux) basedir=$(dirname "$(readlink -f "$0" || echo "$argv0")");;
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
*MSYS*) basedir=`cygpath -w "$basedir"`;;