Skip to content

Commit 91c4f96

Browse files
chore: windows dev and ci. (#56)
1 parent e8e7f69 commit 91c4f96

5 files changed

Lines changed: 59 additions & 23 deletions

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,20 @@ on:
1010

1111
jobs:
1212
ci:
13-
name: CI (Node ${{ matrix.node-version }})
14-
runs-on: ubuntu-latest
13+
name: CI (Node ${{ matrix.version }}-${{ matrix.os }})
1514
strategy:
1615
fail-fast: false
1716
matrix:
18-
node-version:
19-
- '22'
20-
- '24.11.1'
17+
os: [ubuntu-latest, windows-latest]
18+
version: ['22.17.0', '24.11.1']
19+
runs-on: ${{ matrix.os }}
2120
steps:
2221
- name: Checkout
2322
uses: actions/checkout@v4.2.2
2423
- name: Setup Node
2524
uses: actions/setup-node@v4.3.0
2625
with:
27-
node-version: ${{ matrix.node-version }}
26+
node-version: ${{ matrix.version }}
2827
- name: Install Dependencies
2928
run: npm ci
3029
- name: Save error log

package-lock.json

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@
123123
"cycles": "madge src --circular --extensions ts,tsx,js,jsx --ts-config tsconfig.json",
124124
"prettier": "prettier -w .",
125125
"prettier:check": "prettier --check .",
126-
"test": "KNIGHTED_JSX_CLI_TEST=1 vitest run --coverage",
127-
"test:watch": "KNIGHTED_JSX_CLI_TEST=1 vitest",
126+
"test": "cross-env KNIGHTED_JSX_CLI_TEST=1 vitest run --coverage",
127+
"test:watch": "cross-env KNIGHTED_JSX_CLI_TEST=1 vitest",
128128
"test:e2e": "npm run build && npm run setup:wasm && npm run build:fixture && playwright test",
129129
"build:fixture": "node scripts/build-rspack-fixture.mjs",
130130
"demo:node-ssr": "node test/fixtures/node-ssr/render.mjs",
@@ -149,6 +149,7 @@
149149
"@types/react-dom": "^19.2.3",
150150
"@vitest/coverage-v8": "^4.0.14",
151151
"@vitest/eslint-plugin": "^1.6.4",
152+
"cross-env": "^10.1.0",
152153
"eslint": "^9.39.1",
153154
"eslint-plugin-n": "^17.10.3",
154155
"eslint-plugin-playwright": "^2.4.0",

scripts/setup-wasm.mjs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
import { execFileSync, spawnSync } from 'node:child_process'
1+
import { execFileSync } from 'node:child_process'
22
import fs from 'node:fs'
33
import path from 'node:path'
44
import { extract } from 'tar'
55

6+
const npmExecPath = process.env.npm_execpath
7+
const npmBin = process.platform === 'win32' ? 'npm.cmd' : 'npm'
68
const PACKAGE_SPEC =
7-
process.env.WASM_BINDING_PACKAGE ?? '@oxc-parser/binding-wasm32-wasi@^0.99.0'
9+
process.env.WASM_BINDING_PACKAGE ?? '@oxc-parser/binding-wasm32-wasi@^0.105.0'
810
const cwd = process.cwd()
9-
const cliEntry = path.resolve(cwd, 'dist', 'cli', 'init.js')
10-
11-
if (fs.existsSync(cliEntry)) {
12-
const result = spawnSync(process.execPath, [cliEntry, '--skip-config', '--force'], {
13-
cwd,
14-
stdio: 'inherit',
15-
})
16-
17-
process.exit(result.status ?? 0)
18-
}
1911

2012
function runNpmPack() {
21-
const output = execFileSync('npm', ['pack', PACKAGE_SPEC], {
13+
const baseOptions = {
2214
cwd,
2315
encoding: 'utf8',
2416
stdio: ['ignore', 'pipe', 'inherit'],
25-
}).trim()
17+
}
18+
const output = (
19+
npmExecPath
20+
? execFileSync(process.execPath, [npmExecPath, 'pack', PACKAGE_SPEC], baseOptions)
21+
: execFileSync(npmBin, ['pack', PACKAGE_SPEC], {
22+
...baseOptions,
23+
shell: process.platform === 'win32',
24+
})
25+
).trim()
2626
const lines = output.split('\n').filter(Boolean)
2727

2828
return lines[lines.length - 1]

test/next-fixture.test.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,20 @@ const runCommand = (
2121
options: { cwd?: string; env?: NodeJS.ProcessEnv } = {},
2222
) =>
2323
new Promise<void>((resolve, reject) => {
24+
const env: NodeJS.ProcessEnv = { ...process.env, ...options.env }
25+
26+
// Drop undefined env entries to avoid Windows EINVAL from spawn.
27+
for (const key of Object.keys(env)) {
28+
if (env[key] === undefined) {
29+
delete env[key]
30+
}
31+
}
32+
2433
const child = spawn(bin, args, {
2534
cwd: options.cwd,
26-
env: options.env,
35+
env,
2736
stdio: ['ignore', 'pipe', 'pipe'],
37+
shell: process.platform === 'win32',
2838
})
2939

3040
let stderr = ''

0 commit comments

Comments
 (0)