Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function findNodeModules(basePath: string): Promise {
basePath = path.resolve(basePath);
const nodeModules = path.resolve(basePath, 'node_modules');
if (await fsAsPromised.exists(nodeModules)) {
return nodeModules;
} else {
const parent = path.dirname(basePath);
if (parent === basePath) {
return null;
} else {
return findNodeModules(path.dirname(basePath));
}
}
}
export async function findNodeModules(basePath: string): Promise {
basePath = path.resolve(basePath);
const nodeModules = path.resolve(basePath, 'node_modules');
if (await fsAsPromised.exists(nodeModules)) {
return nodeModules;
} else {
const parent = path.dirname(basePath);
if (parent === basePath) {
return null;
} else {
return findNodeModules(path.dirname(basePath));
}
}
}