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