Skip to content

Commit bc18c92

Browse files
committed
Move bun install and tests to test:bun script.
Bun install fails on some Linux distros, so it needs to be moved to a separate install and test script that is optional. It is still run in the GitHub workflow.
1 parent de4d555 commit bc18c92

File tree

8 files changed

+10
-18
lines changed

8 files changed

+10
-18
lines changed

.github/workflows/test.yml

+3
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ jobs:
4848
- name: Unit Tests
4949
run: npm run test:unit
5050

51+
- name: Bun Tests
52+
run: npm run test:bun
53+
5154
- name: E2E Tests
5255
run: npm run test:e2e
5356
if: startsWith(matrix.os, 'ubuntu') && matrix.node == 20

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@
3030
"lint:lockfile": "lockfile-lint",
3131
"lint:markdown": "markdownlint \"**/*.md\" --ignore \"**/node_modules/**/*.md\" --ignore build --config .markdownlint.js",
3232
"lint:src": "eslint --cache --cache-location node_modules/.cache/.eslintcache --ignore-path .gitignore --report-unused-disable-directives .",
33-
"prepare": "src/scripts/install-hooks && test/bun-setup.sh",
33+
"prepare": "src/scripts/install-hooks",
3434
"prepublishOnly": "npm run build",
3535
"prettier": "prettier . --check",
3636
"test": "npm run test:unit && npm run test:e2e",
37+
"test:bun": "test/bun-install.sh && mocha test/bun",
3738
"test:unit": "mocha test test/package-managers/*",
3839
"test:e2e": "./test/e2e.sh",
3940
"ncu": "node build/cli.js"

src/package-managers/bun.ts

-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import path from 'path'
22
import spawn from 'spawn-please'
33
import keyValueBy from '../lib/keyValueBy'
4-
import programError from '../lib/programError'
54
import { Index } from '../types/IndexType'
65
import { NpmOptions } from '../types/NpmOptions'
76
import { Options } from '../types/Options'
@@ -15,12 +14,6 @@ async function spawnBun(
1514
spawnPleaseOptions: SpawnPleaseOptions = {},
1615
spawnOptions: Index<any> = {},
1716
): Promise<{ stdout: string; stderr: string }> {
18-
// Bun not yet supported on Windows.
19-
// @see https://github.com/oven-sh/bun/issues/43
20-
if (process.platform === 'win32') {
21-
programError(npmOptions, 'Bun not yet supported on Windows')
22-
}
23-
2417
const fullArgs = [
2518
...(npmOptions.global ? ['--global'] : []),
2619
...(npmOptions.prefix ? [`--prefix=${npmOptions.prefix}`] : []),

test/bun-setup.sh test/bun-install.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
# Install bun if not installed.
3-
# Must be run in a prepare script instead of devDependencies to avoid npm install failing on Windows.
4-
bun -v &> /dev/null
3+
# Cannot be added to devDependencies as bun currently does not work on Linux.
4+
bun -v &>/dev/null
55
BUN_EXISTS="$?"
66

77
if [ $BUN_EXISTS -ne 0 ]; then
File renamed without changes.

test/package-managers/bun/index.test.ts test/bun/index.test.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
import os from 'os'
2-
import * as bun from '../../../src/package-managers/bun'
3-
import chaiSetup from '../../helpers/chaiSetup'
1+
import * as bun from '../../src/package-managers/bun'
2+
import chaiSetup from '../helpers/chaiSetup'
43

54
chaiSetup()
65

7-
// Bun not yet supported on Windows
8-
const describeSkipWindows = os.platform() === 'win32' ? describe.skip : describe
9-
describeSkipWindows('bun', function () {
6+
describe('bun', function () {
107
it('list', async () => {
118
const result = await bun.list({ cwd: __dirname })
129
result.should.have.property('ncu-test-v2')
File renamed without changes.

test/doctor.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,6 @@ else {
483483
testFail({ packageManager: 'yarn' })
484484
})
485485

486-
// Bun not yet supported on Windows
487-
// const describeSkipWindows = os.platform() === 'win32' ? describe.skip : describe
488486
// TODO: Works locally, but not in GitHub action.
489487
describe.skip('bun', () => {
490488
testPass({ packageManager: 'bun' })

0 commit comments

Comments
 (0)