mirror of
https://github.com/status-im/react-native.git
synced 2025-01-10 01:25:39 +00:00
5cf7f040a5
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
16 lines
601 B
JavaScript
16 lines
601 B
JavaScript
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;
|
|
};
|