Symlink support for packager
Summary: I saw we have quite a few user requests for symlink support... **Test plan (required)** 1. Create a symlink in `node_modules` (for instance use `npm link`) 2. Run `npm start` 3. Profit! **Code formatting** Look around. Match the style of the rest of the codebase. See also the simple [style guide](https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md#style-guide). For more info, see the ["Pull Requests" section of our "Contributing" guidelines](https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md#pull-requests). Closes https://github.com/facebook/react-native/pull/9009 Differential Revision: D3648828 Pulled By: matryoshcow fbshipit-source-id: 99cf313bfa70324ca904fa6919ef112180974e9e
This commit is contained in:
parent
f634a0fc23
commit
5cf7f040a5
|
@ -0,0 +1,15 @@
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
module.exports = function findSymlinksPaths(lookupFolder) {
|
||||
const timeStart = Date.now();
|
||||
const folders = fs.readdirSync(lookupFolder);
|
||||
const resolvedSymlinks = folders.map(folder => path.resolve(lookupFolder, folder))
|
||||
.filter(folderPath => fs.lstatSync(folderPath).isSymbolicLink())
|
||||
.map(symlink => path.resolve(process.cwd(), fs.readlinkSync(symlink)));
|
||||
const timeEnd = Date.now();
|
||||
|
||||
console.log(`Scanning ${folders.length} folders for symlinks in ${lookupFolder} (${timeEnd - timeStart}ms)`);
|
||||
|
||||
return resolvedSymlinks;
|
||||
};
|
|
@ -12,12 +12,16 @@ const chalk = require('chalk');
|
|||
const formatBanner = require('./formatBanner');
|
||||
const path = require('path');
|
||||
const runServer = require('./runServer');
|
||||
const findSymlinksPaths = require('./findSymlinksPaths');
|
||||
|
||||
/**
|
||||
* Starts the React Native Packager Server.
|
||||
*/
|
||||
function server(argv, config, args) {
|
||||
args.projectRoots = args.projectRoots.concat(args.root);
|
||||
args.projectRoots = args.projectRoots.concat(
|
||||
args.root,
|
||||
findSymlinkPaths(path.resolve(process.cwd(), 'node_modules'))
|
||||
);
|
||||
|
||||
console.log(formatBanner(
|
||||
'Running packager on port ' + args.port + '.\n\n' +
|
||||
|
|
Loading…
Reference in New Issue