Skip to content

Commit

Permalink
Enable bun on Windows (#1401)
Browse files Browse the repository at this point in the history
  • Loading branch information
raineorshine committed Apr 25, 2024
1 parent 02e93f8 commit c58decf
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 14 deletions.
135 changes: 135 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"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",
Expand Down Expand Up @@ -80,6 +80,7 @@
"@types/update-notifier": "^6.0.8",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"bun": "^1.1.4",
"camelcase": "^6.3.0",
"chai": "^4.3.10",
"chai-as-promised": "^7.1.1",
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const install = async (

pkgsNormalized.forEach(async pkgFile => {
const packageManager = await getPackageManagerForInstall(options, pkgFile)
const cmd = packageManager + (process.platform === 'win32' ? '.cmd' : '')
const cmd = packageManager + (process.platform === 'win32' && packageManager !== 'bun' ? '.cmd' : '')
const cwd = options.cwd || path.resolve(pkgFile, '..')
let stdout = ''
try {
Expand Down
7 changes: 0 additions & 7 deletions src/package-managers/bun.ts
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion test/doctor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +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', () => {
Expand Down
5 changes: 1 addition & 4 deletions test/package-managers/bun/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import os from 'os'
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

0 comments on commit c58decf

Please sign in to comment.