diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 829c4101..d711bc92 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -48,6 +48,9 @@ jobs: - name: Unit Tests run: npm run test:unit + - name: Bun Tests + run: npm run test:bun + - name: E2E Tests run: npm run test:e2e if: startsWith(matrix.os, 'ubuntu') && matrix.node == 20 diff --git a/package.json b/package.json index 7573fc77..c4f12d2c 100644 --- a/package.json +++ b/package.json @@ -30,10 +30,11 @@ "lint:lockfile": "lockfile-lint", "lint:markdown": "markdownlint \"**/*.md\" --ignore \"**/node_modules/**/*.md\" --ignore build --config .markdownlint.js", "lint:src": "eslint --cache --cache-location node_modules/.cache/.eslintcache --ignore-path .gitignore --report-unused-disable-directives .", - "prepare": "src/scripts/install-hooks && test/bun-setup.sh", + "prepare": "src/scripts/install-hooks", "prepublishOnly": "npm run build", "prettier": "prettier . --check", "test": "npm run test:unit && npm run test:e2e", + "test:bun": "test/bun-install.sh && mocha test/bun", "test:unit": "mocha test test/package-managers/*", "test:e2e": "./test/e2e.sh", "ncu": "node build/cli.js" diff --git a/src/package-managers/bun.ts b/src/package-managers/bun.ts index b4715a9d..be840f6e 100644 --- a/src/package-managers/bun.ts +++ b/src/package-managers/bun.ts @@ -1,7 +1,6 @@ import path from 'path' import spawn from 'spawn-please' import keyValueBy from '../lib/keyValueBy' -import programError from '../lib/programError' import { Index } from '../types/IndexType' import { NpmOptions } from '../types/NpmOptions' import { Options } from '../types/Options' @@ -15,12 +14,6 @@ async function spawnBun( spawnPleaseOptions: SpawnPleaseOptions = {}, spawnOptions: Index = {}, ): Promise<{ stdout: string; stderr: string }> { - // Bun not yet supported on Windows. - // @see https://github.com/oven-sh/bun/issues/43 - if (process.platform === 'win32') { - programError(npmOptions, 'Bun not yet supported on Windows') - } - const fullArgs = [ ...(npmOptions.global ? ['--global'] : []), ...(npmOptions.prefix ? [`--prefix=${npmOptions.prefix}`] : []), diff --git a/test/bun-setup.sh b/test/bun-install.sh similarity index 67% rename from test/bun-setup.sh rename to test/bun-install.sh index 62f5571b..40005b9e 100755 --- a/test/bun-setup.sh +++ b/test/bun-install.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Install bun if not installed. -# Must be run in a prepare script instead of devDependencies to avoid npm install failing on Windows. -bun -v &> /dev/null +# Cannot be added to devDependencies as bun currently does not work on Linux. +bun -v &>/dev/null BUN_EXISTS="$?" if [ $BUN_EXISTS -ne 0 ]; then diff --git a/test/package-managers/bun/bun.lockb b/test/bun/bun.lockb similarity index 100% rename from test/package-managers/bun/bun.lockb rename to test/bun/bun.lockb diff --git a/test/package-managers/bun/index.test.ts b/test/bun/index.test.ts similarity index 51% rename from test/package-managers/bun/index.test.ts rename to test/bun/index.test.ts index a2fd263d..2f523a29 100644 --- a/test/package-managers/bun/index.test.ts +++ b/test/bun/index.test.ts @@ -1,12 +1,9 @@ -import os from 'os' -import * as bun from '../../../src/package-managers/bun' -import chaiSetup from '../../helpers/chaiSetup' +import * as bun from '../../src/package-managers/bun' +import chaiSetup from '../helpers/chaiSetup' chaiSetup() -// Bun not yet supported on Windows -const describeSkipWindows = os.platform() === 'win32' ? describe.skip : describe -describeSkipWindows('bun', function () { +describe('bun', function () { it('list', async () => { const result = await bun.list({ cwd: __dirname }) result.should.have.property('ncu-test-v2') diff --git a/test/package-managers/bun/package.json b/test/bun/package.json similarity index 100% rename from test/package-managers/bun/package.json rename to test/bun/package.json diff --git a/test/doctor.test.ts b/test/doctor.test.ts index e2729ccd..8999f749 100644 --- a/test/doctor.test.ts +++ b/test/doctor.test.ts @@ -483,8 +483,6 @@ else { testFail({ packageManager: 'yarn' }) }) - // Bun not yet supported on Windows - // const describeSkipWindows = os.platform() === 'win32' ? describe.skip : describe // TODO: Works locally, but not in GitHub action. describe.skip('bun', () => { testPass({ packageManager: 'bun' })