UNPKG

845 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 });
10exports.findUp = void 0;
11const fs_1 = require("fs");
12const path = require("path");
13function 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}
30exports.findUp = findUp;