Filipe Silva 6d5dfa01c0 test: add license test (#4561)
* 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
2017-02-17 14:49:04 +00:00

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;
}