feat: external config loading

+refactor many pieces
This commit is contained in:
Igor Randjelovic
2020-11-21 13:34:09 +01:00
parent b1bc2640db
commit 46853d2c83
15 changed files with 358 additions and 107 deletions

View File

@@ -0,0 +1,24 @@
import { getPackageJson, getProjectRootPath } from './project';
import path from 'path';
export function getAllDependencies(): string[] {
const packageJSON = getPackageJson();
console.log(packageJSON);
return [
...Object.keys(packageJSON.dependencies ?? {}),
...Object.keys(packageJSON.devDependencies ?? {}),
];
}
export function getDependencyPath(dependencyName: string): string | null {
try {
const resolvedPath = require.resolve(`${dependencyName}/package.json`, {
paths: [getProjectRootPath()],
});
return path.dirname(resolvedPath);
} catch (err) {
return null;
}
}