UNPKG

820 BJavaScriptView Raw
1"use strict";
2/**
3 * @license
4 * Copyright Google Inc. 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 });
10const fs_1 = require("fs");
11const path = require("path");
12function 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}
29exports.findUp = findUp;