Skip to content

Commit

Permalink
Resolve app paths from realpath of CWD, fix facebook#637 (facebook#648)
Browse files Browse the repository at this point in the history
* Resolve app paths from realpath of CWD, fix facebook#637

* Use new resolveApp() for NODE_PATH too
  • Loading branch information
motiz88 authored and feiqitian committed Oct 25, 2016
1 parent 6182bb1 commit a5312e2
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
// @remove-on-eject-end

var path = require('path');
var fs = require('fs');

// Make sure any symlinks in the project folder are resolved:
// https://github.com/facebookincubator/create-react-app/issues/637
var appDirectory = fs.realpathSync(process.cwd());
function resolveApp(relativePath) {
return path.resolve(appDirectory, relativePath);
}

// We support resolving modules according to `NODE_PATH`.
// This lets you use absolute paths in imports inside large monorepos:
Expand All @@ -25,11 +33,7 @@ var path = require('path');
var nodePaths = (process.env.NODE_PATH || '')
.split(process.platform === 'win32' ? ';' : ':')
.filter(Boolean)
.map(p => path.resolve(p));

function resolveApp(relativePath) {
return path.resolve(relativePath);
}
.map(resolveApp);

// config after eject: we're in ./config/
module.exports = {
Expand Down

0 comments on commit a5312e2

Please sign in to comment.