mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-23 15:36:23 +08:00
* test: add license test * only check prod dependencies * remove findup dep * also check dev deps * add map-stream to ignore list * remove license-checker * add comment * use logger * fix lint errors
24 lines
561 B
TypeScript
24 lines
561 B
TypeScript
import * as path from 'path';
|
|
import { existsSync } from 'fs';
|
|
|
|
export function findUp(name: string, from: string, stopOnNodeModules = false) {
|
|
let currentDir = from;
|
|
while (currentDir && currentDir !== path.parse(currentDir).root) {
|
|
const p = path.join(currentDir, name);
|
|
if (existsSync(p)) {
|
|
return p;
|
|
}
|
|
|
|
if (stopOnNodeModules) {
|
|
const nodeModuleP = path.join(currentDir, 'node_modules');
|
|
if (existsSync(nodeModuleP)) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
currentDir = path.dirname(currentDir);
|
|
}
|
|
|
|
return null;
|
|
}
|