diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3a39e0f..b6f5891 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,11 +4,12 @@ permissions: contents: read jobs: test: - name: "Test on Node.js ${{ matrix.node-version }}" - runs-on: ubuntu-latest + name: Test(Node ${{ matrix.node }} on ${{ matrix.os }}) + runs-on: ${{ matrix.os }} strategy: matrix: - node-version: [ 18,20 ] + os: [ubuntu-latest, windows-latest] + node: [ 18, 20 ] steps: - name: checkout uses: actions/checkout@v4 diff --git a/eslint-cjs-to-esm.js b/eslint-cjs-to-esm.js index 730f909..46b9123 100644 --- a/eslint-cjs-to-esm.js +++ b/eslint-cjs-to-esm.js @@ -3,7 +3,9 @@ import { execa } from "execa"; import { createRequire } from "node:module"; const require = createRequire(import.meta.url); -const eslintBin = require.resolve(".bin/eslint"); +const isWindows = /^win/.test(process.platform); +const eslintBinBasePath = ".bin/eslint"; +const eslintBin = require.resolve(isWindows ? `${eslintBinBasePath}.cmd` : eslintBinBasePath); import url from "node:url"; import path from "node:path"; @@ -23,8 +25,10 @@ try { if (process.env.DEBUG === "eslint-cjs-to-esm") { console.debug({ args, eslintBin, builtinConfig }); } - const { stdout, stderr } = await execa("node", [ - eslintBin, + const command = isWindows ? eslintBin : "node"; + const platformArguments = isWindows ? [] : [eslintBin]; + const { stdout, stderr } = await execa(command, [ + ...platformArguments, "--config", builtinConfig, ...args], { diff --git a/package.json b/package.json index 18aa6bf..bf7eac0 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ ".eslintrc.cjs" ], "scripts": { - "test": "expected-exit-status 1 --stdout '/\\d+ problems/' --command 'node eslint-cjs-to-esm.js \"./test-fixtures/*\"'" + "test": "expected-exit-status 1 --stdout \"/\\d+ problems/\" --command \"node eslint-cjs-to-esm.js \"\"./test-fixtures/*.ts\"\"\"" }, "devDependencies": { "expected-exit-status": "^3.1.0"