UNPKG

927 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const path = require("path");
4const fs_1 = require("fs");
5function 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}
28exports.findUp = findUp;
29//# sourceMappingURL=/users/hansl/sources/angular-cli/utilities/find-up.js.map
\No newline at end of file