Skip to content

Commit

Permalink
fix: searching for aws-cdk-lim npm module
Browse files Browse the repository at this point in the history
  • Loading branch information
ServerlessLife committed Aug 6, 2024
1 parent 3a52f55 commit aad2605
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions src/utils/findNpmPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,13 @@ export async function findNpmPath(dir: string, moduleName: string) {
* @returns
*/
async function checkModuleInPackageJson(dir: string, moduleName: string) {
const packageJsonPath = path.join(dir, "package.json");
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf8"));
const dependencies = packageJson.dependencies || {};
const devDependencies = packageJson.devDependencies || {};
if (dependencies[moduleName] || devDependencies[moduleName]) {
const modulePath = path.join(dir, "node_modules", moduleName);
const modulePath = path.join(dir, "node_modules", moduleName);

try {
await fs.access(modulePath);
} catch {
return undefined;
}

return modulePath;
try {
await fs.access(modulePath);
} catch {
return undefined;
}
return undefined;

return modulePath;
}

0 comments on commit aad2605

Please sign in to comment.