1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4  value: true
5});
6exports.getModulesPaths = getModulesPaths;
7exports.getWorkspaceRoot = getWorkspaceRoot;
8function _findYarnWorkspaceRoot() {
9  const data = _interopRequireDefault(require("find-yarn-workspace-root"));
10  _findYarnWorkspaceRoot = function () {
11    return data;
12  };
13  return data;
14}
15function _path() {
16  const data = _interopRequireDefault(require("path"));
17  _path = function () {
18    return data;
19  };
20  return data;
21}
22function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23/** Wraps `findWorkspaceRoot` and guards against having an empty `package.json` file in an upper directory. */
24function getWorkspaceRoot(projectRoot) {
25  try {
26    return (0, _findYarnWorkspaceRoot().default)(projectRoot);
27  } catch (error) {
28    if (error.message.includes('Unexpected end of JSON input')) {
29      return null;
30    }
31    throw error;
32  }
33}
34function getModulesPaths(projectRoot) {
35  const paths = [];
36
37  // Only add the project root if it's not the current working directory
38  // this minimizes the chance of Metro resolver breaking on new Node.js versions.
39  const workspaceRoot = getWorkspaceRoot(_path().default.resolve(projectRoot)); // Absolute path or null
40  if (workspaceRoot) {
41    paths.push(_path().default.resolve(projectRoot));
42    paths.push(_path().default.resolve(workspaceRoot, 'node_modules'));
43  }
44  return paths;
45}
46//# sourceMappingURL=getModulesPaths.js.map