Skip to content

Commit 0c5429e

Browse files
authored
fix(repo): PR linter optimization (#4584)
1 parent 536fa99 commit 0c5429e

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

.github/workflows/pr-title-linter.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,11 @@ jobs:
2020
show-progress: false
2121
sparse-checkout: |
2222
commitlint.config.ts
23-
package.json
2423
packages/*/package.json
2524
sparse-checkout-cone-mode: false
2625

27-
- name: Install PNPM
28-
uses: pnpm/action-setup@v4
29-
3026
- name: Lint Pull Request Title
3127
run: |
32-
pnpm install
33-
echo '${{ github.event.pull_request.title }}' | pnpm commitlint --config commitlint.config.ts
28+
npm init --scope=clerk --yes
29+
npm i --save-dev @commitlint/config-conventional @commitlint/cli globby --audit=false --fund=false
30+
echo '${{ github.event.pull_request.title }}' | npm exec @commitlint/cli -- --config commitlint.config.ts

commitlint.config.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
// All imports must be accounted for per `npm i` in .github/workflows/pr-title-linter.yml
2-
import { globbySync } from 'globby';
3-
import { readFileSync } from 'node:fs';
2+
import { readdirSync, readFileSync, statSync } from 'node:fs';
3+
import { join } from 'node:path';
44

55
const getPackageNames = () => {
6-
const files = globbySync('./packages/*/package.json');
7-
const names = files.map(f => JSON.parse(readFileSync(f, 'utf8')).name as string);
8-
return names.map(n => n.split('/').pop());
6+
const packagesDir = './packages';
7+
const entries = readdirSync(packagesDir);
8+
const packageNames = entries
9+
.filter(entry => {
10+
const fullPath = join(packagesDir, entry);
11+
return statSync(fullPath).isDirectory();
12+
})
13+
.map(dir => {
14+
const packageJsonPath = join(packagesDir, dir, 'package.json');
15+
try {
16+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
17+
return packageJson.name.split('/').pop();
18+
} catch {
19+
// Ignore directories without a package.json
20+
return null;
21+
}
22+
})
23+
.filter(Boolean);
24+
return packageNames;
925
};
1026

1127
const Configuration = {

0 commit comments

Comments
 (0)