1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
10 | exports.findAllNodeModules = void 0;
|
11 | const fs_1 = require("fs");
|
12 | const path = require("path");
|
13 | const is_directory_1 = require("./is-directory");
|
14 | function findAllNodeModules(from, root) {
|
15 | const nodeModules = [];
|
16 | let current = from;
|
17 | while (current && current !== root) {
|
18 | const potential = path.join(current, 'node_modules');
|
19 | if (fs_1.existsSync(potential) && is_directory_1.isDirectory(potential)) {
|
20 | nodeModules.push(potential);
|
21 | }
|
22 | const next = path.dirname(current);
|
23 | if (next === current) {
|
24 | break;
|
25 | }
|
26 | current = next;
|
27 | }
|
28 | return nodeModules;
|
29 | }
|
30 | exports.findAllNodeModules = findAllNodeModules;
|