From 8d67f28d0281ac4330f283495b7f48286654ad7d Mon Sep 17 00:00:00 2001 From: Issack John Date: Thu, 7 Mar 2024 01:41:02 -0800 Subject: [PATCH] Fix Cross-platform issue with npm script (#397) * Make commands work cross-env * make npm format work as well. --- .github/workflows/test.yml | 4 +--- package.json | 10 +++++----- tests/run.mjs | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ad730d4a5..f6ba37470 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,8 +43,6 @@ jobs: strategy: matrix: browser: [chrome, firefox, safari] - env: - BROWSER: ${{ matrix.browser }} steps: - name: Checkout Branch uses: actions/checkout@v3 @@ -58,4 +56,4 @@ jobs: - name: Run tests run: | echo "Running in $BROWSER" - node tests/run.mjs + npm run test:${{ matrix.browser }} diff --git a/package.json b/package.json index b9d654e9b..f185896c7 100644 --- a/package.json +++ b/package.json @@ -21,11 +21,11 @@ "lint:fix": "eslint \"**/*.{js,mjs,jsx,ts,tsx}\" --fix", "pretty:check": "prettier --check ./", "pretty:fix": "prettier --write ./", - "format": "npm run pretty:fix ; npm run lint:fix", - "test:chrome": "BROWSER=chrome node tests/run.mjs", - "test:firefox": "BROWSER=firefox node tests/run.mjs", - "test:safari": "BROWSER=safari node tests/run.mjs", - "test:edge": "BROWSER=edge node tests/run.mjs" + "format": "npm run pretty:fix && npm run lint:fix", + "test:chrome": "node tests/run.mjs --browser chrome", + "test:firefox": "node tests/run.mjs --browser firefox", + "test:safari": "node tests/run.mjs --browser safari", + "test:edge": "node tests/run.mjs --browser edge" }, "devDependencies": { "@babel/core": "^7.21.3", diff --git a/tests/run.mjs b/tests/run.mjs index 7f74e95e3..a71f2fb57 100644 --- a/tests/run.mjs +++ b/tests/run.mjs @@ -39,7 +39,7 @@ const options = commandLineArgs(optionDefinitions); if ("help" in options) printHelp(); -const BROWSER = options?.browser || process.env.BROWSER; +const BROWSER = options?.browser; if (!BROWSER) printHelp("No browser specified, use $BROWSER or --browser");