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