Skip to content

Commit

Permalink
fix(linter): ensure package detection works in PnP
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav committed Jul 31, 2023
1 parent 989f7f8 commit 0984160
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/eslint-plugin/src/utils/config-utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { detectPackageManager } from '@nx/devkit';
import { execSync } from 'child_process';
import { accessSync } from 'fs';

/**
Expand All @@ -6,8 +8,16 @@ import { accessSync } from 'fs';
* @returns
*/
export function packageExists(name: string): boolean {
const pm = detectPackageManager();
if (pm === 'yarn') {
try {
execSync(`yarn info ${name}`);
return true;
} catch (e) {
return false;
}
}
try {
// TODO(meeroslav): This will not work once we start using yarn Berry with PnP
accessSync(`./node_modules/.bin/${name}`);
return true;
} catch (e) {
Expand Down

0 comments on commit 0984160

Please sign in to comment.