[READ-ONLY] a fast, modern browser for the npm registry
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: run lint without installing the repo (#757)

authored by

Wojciech Maj and committed by
GitHub
b8584f32 0c03bb12

+35 -6
+2 -6
.github/workflows/ci.yml
··· 32 32 33 33 - uses: pnpm/action-setup@1e1c8eafbd745f64b1ef30a7d7ed7965034c486c 34 34 name: Install pnpm 35 - with: 36 - cache: true 37 - 38 - - name: 📦 Install dependencies 39 - run: pnpm install 35 + # pnpm cache skipped deliberately as the project is not actually installed here 40 36 41 37 - name: 🔠 Lint project 42 - run: pnpm lint 38 + run: node scripts/lint.ts 43 39 44 40 test: 45 41 runs-on: ubuntu-latest
+33
scripts/lint.ts
··· 1 + /** 2 + * This script runs oxlint and oxfmt in a CI environment, without the need to install the entire 3 + * project. It reads the required version from pnpm-lock.yaml and executes the linters accordingly. 4 + * It's "stupid by design" so it could work in minimal Node.js environments. 5 + */ 6 + 7 + import { spawnSync } from 'node:child_process' 8 + 9 + function getDependencyVersion(dependencyName: string): string { 10 + const result = spawnSync('npm', ['pkg', 'get', `devDependencies.${dependencyName}`], { 11 + encoding: 'utf8', 12 + }) 13 + 14 + if (result.status) { 15 + throw new Error(`Command failed: pnpm info ${dependencyName} version`) 16 + } 17 + 18 + return JSON.parse(result.stdout) 19 + } 20 + 21 + function runCommand(command: string, args: string[]) { 22 + const result = spawnSync(command, args, { stdio: 'inherit' }) 23 + 24 + if (result.status) { 25 + throw new Error(`Command failed: ${command} ${args.join(' ')}`) 26 + } 27 + } 28 + 29 + const oxlintVersion = getDependencyVersion('oxlint') 30 + const oxfmtVersion = getDependencyVersion('oxfmt') 31 + 32 + runCommand('pnpx', [`oxlint@${oxlintVersion}`]) 33 + runCommand('pnpx', [`oxfmt@${oxfmtVersion}`, '--check'])