UNPKG

966 BJavaScriptView Raw
1"use strict";
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10exports.findAllNodeModules = void 0;
11const fs_1 = require("fs");
12const path = require("path");
13const is_directory_1 = require("./is-directory");
14function 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}
30exports.findAllNodeModules = findAllNodeModules;