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