Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symlink support for packager #9009

Closed
wants to merge 10 commits into from
9 changes: 9 additions & 0 deletions local-cli/server/findSymlinksPaths.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const path = require('path');
const fs = require('fs');

module.exports = function findSymlinksPaths(lookupFolder) {
return fs.readdirSync(lookupFolder)
.map(f => path.resolve(lookupFolder, f))
.filter(d => fs.lstatSync(d).isSymbolicLink())
.map(s => path.resolve(process.cwd(), fs.readlinkSync(s)));
};
4 changes: 4 additions & 0 deletions local-cli/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const parseCommandLine = require('../util/parseCommandLine');
const path = require('path');
const Promise = require('promise');
const runServer = require('./runServer');
const findSymlinksPaths = require('./findSymlinksPaths');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it appears you're requiring the symlink resolver but you're not actually using it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. But on the other hand there is no way to know if you're using symlinks or not.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean is - you might actually want to call findSymlinkPaths to... you know... find the symlink paths and perhaps append them where they belong, no? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say I want to return an array of resolved symlink paths from this function and apply them wherever it'll be needed.


/**
* Starts the React Native Packager Server.
Expand Down Expand Up @@ -74,6 +75,9 @@ function _server(argv, config, resolve, reject) {
? argToArray(args.projectRoots)
: config.getProjectRoots();

args.projectRoots = args.projectRoots
.concat(findSymlinksPaths(path.resolve(process.cwd(), 'node_modules')));
Copy link
Contributor

@bestander bestander Jul 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means 750 sync lstat operations during packager start.


if (args.root) {
const additionalRoots = argToArray(args.root);
additionalRoots.forEach(root => {
Expand Down