Skip to content

Commit

Permalink
Move bun install and tests to test:bun script.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
raineorshine committed Apr 26, 2024
1 parent de4d555 commit bc18c92
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Expand Up @@ -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
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -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"
Expand Down
7 changes: 0 additions & 7 deletions 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'
Expand All @@ -15,12 +14,6 @@ async function spawnBun(
spawnPleaseOptions: SpawnPleaseOptions = {},
spawnOptions: Index<any> = {},
): 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}`] : []),
Expand Down
4 changes: 2 additions & 2 deletions test/bun-setup.sh → 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
Expand Down
File renamed without changes.
@@ -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')
Expand Down
File renamed without changes.
2 changes: 0 additions & 2 deletions test/doctor.test.ts
Expand Up @@ -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' })
Expand Down

0 comments on commit bc18c92

Please sign in to comment.