Skip to content

Commit

Permalink
Refactor how symlinks are found in local-cli, support scoped modules
Browse files Browse the repository at this point in the history
This PR refactors the symlink finding logic in order to support nested symlinked modules as well as scoped NPM modules.
  • Loading branch information
Adam Miskiewicz committed Sep 3, 2017
1 parent e964a7f commit 9690dad
Show file tree
Hide file tree
Showing 5 changed files with 841 additions and 59 deletions.
19 changes: 10 additions & 9 deletions local-cli/util/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
'use strict';

const blacklist = require('metro-bundler/src/blacklist');
const findSymlinksPaths = require('./findSymlinksPaths');
const findSymlinkedModules = require('./findSymlinkedModules');
const fs = require('fs');
const getPolyfills = require('../../rn-get-polyfills');
const invariant = require('fbjs/lib/invariant');
Expand Down Expand Up @@ -150,14 +150,15 @@ function getProjectPath() {
return path.resolve(__dirname, '../..');
}

const resolveSymlink = (roots) =>
roots.concat(
findSymlinksPaths(
path.join(getProjectPath(), 'node_modules'),
roots
)
const resolveSymlinksForRoots = roots =>
roots.reduce(
(arr, rootPath) => arr.concat(
findSymlinkedModules(rootPath, roots)
),
[...roots]
);


/**
* Module capable of getting the configuration out of a given file.
*
Expand All @@ -177,9 +178,9 @@ const Config = {
getProjectRoots: () => {
const root = process.env.REACT_NATIVE_APP_ROOT;
if (root) {
return resolveSymlink([path.resolve(root)]);
return resolveSymlinksForRoots([path.resolve(root)]);
}
return resolveSymlink([getProjectPath()]);
return resolveSymlinksForRoots([getProjectPath()]);
},
getProvidesModuleNodeModules: () => providesModuleNodeModules.slice(),
getSourceExts: () => [],
Expand Down
Loading

0 comments on commit 9690dad

Please sign in to comment.