Skip to content

Commit 53128d9

Browse files
authored
Merge pull request #51 from kurtstohrer/fix/ci-node20-globsync
fix(test): Node-20-compatible readdir instead of fs.globSync (unblocks CI + publish)
2 parents febd1fe + f5ffd00 commit 53128d9

4 files changed

Lines changed: 36 additions & 4 deletions

File tree

.github/workflows/publish.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ name: Publish to npm
33
on:
44
release:
55
types: [published]
6+
# Called directly by release.yml after it cuts the tag/release. A reusable
7+
# workflow_call is a direct invocation, so it runs even though the release
8+
# was created with GITHUB_TOKEN (whose events don't trigger other workflows).
9+
workflow_call:
10+
inputs:
11+
dry-run:
12+
description: 'Dry run (skip actual publish)'
13+
type: boolean
14+
default: false
615
workflow_dispatch:
716
inputs:
817
dry-run:

.github/workflows/release.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ jobs:
99
runs-on: ubuntu-latest
1010
permissions:
1111
contents: write
12+
outputs:
13+
changed: ${{ steps.version.outputs.changed }}
14+
version: ${{ steps.version.outputs.version }}
1215
steps:
1316
- uses: actions/checkout@v4
1417
with:
@@ -41,3 +44,13 @@ jobs:
4144
gh release create "$TAG" \
4245
--title "$TAG" \
4346
--generate-notes
47+
48+
# Publish straight after the release is cut. Called as a reusable workflow
49+
# (not via the `release: published` event, which GITHUB_TOKEN-created releases
50+
# never fire) so a version bump on main now auto-publishes to npm with no
51+
# manual dispatch and no PAT. Skipped when the version didn't change.
52+
publish:
53+
needs: release
54+
if: needs.release.outputs.changed == 'true'
55+
uses: ./.github/workflows/publish.yml
56+
secrets: inherit

src/plugin/__tests__/transform-react.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it, expect } from 'vitest'
2-
import { globSync, readFileSync } from 'node:fs'
2+
import { readdirSync, readFileSync } from 'node:fs'
33
import path from 'node:path'
44
import { fileURLToPath } from 'node:url'
55
import ts from 'typescript'
@@ -354,7 +354,12 @@ describe('transformJSX', () => {
354354
path.dirname(fileURLToPath(import.meta.url)),
355355
'../../../playgrounds/simple/react-vite'
356356
)
357-
const files = globSync('src/**/*.{tsx,jsx}', { cwd: playgroundRoot })
357+
// Recursive readdir (Node 18.17+/20) — NOT fs.globSync, which is Node 22+
358+
// and would throw on CI's Node 20.
359+
const files = readdirSync(path.join(playgroundRoot, 'src'), { recursive: true })
360+
.map(String)
361+
.filter((f) => f.endsWith('.tsx') || f.endsWith('.jsx'))
362+
.map((f) => path.join('src', f))
358363
expect(files.length).toBeGreaterThan(0)
359364
for (const rel of files) {
360365
const file = path.join(playgroundRoot, rel)

src/plugin/__tests__/transform-svelte.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it, expect } from 'vitest'
2-
import { globSync, readFileSync } from 'node:fs'
2+
import { readdirSync, readFileSync } from 'node:fs'
33
import path from 'node:path'
44
import { fileURLToPath } from 'node:url'
55
import { compile } from 'svelte/compiler'
@@ -287,7 +287,12 @@ describe('transformSvelte', () => {
287287
path.dirname(fileURLToPath(import.meta.url)),
288288
'../../../playgrounds/simple/svelte-vite'
289289
)
290-
const files = globSync('src/**/*.svelte', { cwd: playgroundRoot })
290+
// Recursive readdir (Node 18.17+/20) — NOT fs.globSync, which is Node 22+
291+
// and would throw on CI's Node 20.
292+
const files = readdirSync(path.join(playgroundRoot, 'src'), { recursive: true })
293+
.map(String)
294+
.filter((f) => f.endsWith('.svelte'))
295+
.map((f) => path.join('src', f))
291296
expect(files.length).toBeGreaterThan(0)
292297
for (const rel of files) {
293298
const file = path.join(playgroundRoot, rel)

0 commit comments

Comments
 (0)