1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const path = require("path");
|
4 | const fs_1 = require("fs");
|
5 | function findUp(names, from, stopOnNodeModules = false) {
|
6 | if (!Array.isArray(names)) {
|
7 | names = [names];
|
8 | }
|
9 | const root = path.parse(from).root;
|
10 | let currentDir = from;
|
11 | while (currentDir && currentDir !== root) {
|
12 | for (const name of names) {
|
13 | const p = path.join(currentDir, name);
|
14 | if (fs_1.existsSync(p)) {
|
15 | return p;
|
16 | }
|
17 | }
|
18 | if (stopOnNodeModules) {
|
19 | const nodeModuleP = path.join(currentDir, 'node_modules');
|
20 | if (fs_1.existsSync(nodeModuleP)) {
|
21 | return null;
|
22 | }
|
23 | }
|
24 | currentDir = path.dirname(currentDir);
|
25 | }
|
26 | return null;
|
27 | }
|
28 | exports.findUp = findUp;
|
29 |
|
\ | No newline at end of file |