Skip to content

Commit

Permalink
fix: not working on Windows 10 (#21)
Browse files Browse the repository at this point in the history
* BREAKING CHANGE: Changed from running eslint via node to npm.

* test: add os matrix

* Revert "BREAKING CHANGE: Changed from running eslint via node to npm."

This reverts commit 8718c8b.

* fix: not working on Windows 10

* test: change ' to "

* test: fix for macOS/linux

* revert style
  • Loading branch information
starnayuta committed Feb 3, 2024
1 parent 018695b commit 4152c34
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions eslint-cjs-to-esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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], {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 4152c34

Please sign in to comment.