diff --git a/package-lock.json b/package-lock.json index 64bc66bd..3c16aab0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,7 +38,6 @@ "@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", @@ -1455,110 +1454,6 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, - "node_modules/@oven/bun-darwin-aarch64": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/@oven/bun-darwin-aarch64/-/bun-darwin-aarch64-1.1.4.tgz", - "integrity": "sha512-/eysHyAfoEda+/HHLVx0u5f/ZGxb6bR/xLQ4E/u/c5Emue5npeJBLD2P8Kjt9efz/A0xalPW8jHvtuEmYTnuoA==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@oven/bun-darwin-x64": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/@oven/bun-darwin-x64/-/bun-darwin-x64-1.1.4.tgz", - "integrity": "sha512-d9oUj2e5TCR3UzhTDYgASLSQHDh2UCVS7UeOq32cPbhY4bBa3UQPO8Mn5HXNBgXck1EoFHRjrB44qgNPNUWJvw==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@oven/bun-darwin-x64-baseline": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/@oven/bun-darwin-x64-baseline/-/bun-darwin-x64-baseline-1.1.4.tgz", - "integrity": "sha512-VJBlJNMXV7VgMa2yrni6k/qaFVEAZikPaKF315TGrCFUVjBFcUSMpmQDAOFfajzqzdaFcZCrCTPMlgfvASptCA==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@oven/bun-linux-aarch64": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64/-/bun-linux-aarch64-1.1.4.tgz", - "integrity": "sha512-iLZC9Kk9T/sKVNn0VZODmCk9wSqPy49yTY3J0HXtYRzaeXO3f7M22SuqMZibU0XC4kCPCYNG/4x3+mkBpVYlBw==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@oven/bun-linux-x64": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64/-/bun-linux-x64-1.1.4.tgz", - "integrity": "sha512-W4ASgbY/+42IIa7R5fkLVptLt59P5d0jlpEYDghJLWK0bdosfMAu3xB05FuqO90Te7BI+LWMaGFoKAXLcatjdg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@oven/bun-linux-x64-baseline": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-baseline/-/bun-linux-x64-baseline-1.1.4.tgz", - "integrity": "sha512-gswEWKO7ajyosUqitcv7h/MO+dylt8Qb5CwnSOy6NQNyu77LKGhpgy2g5aASN9Vlbubihzhze1mRhCnhz41gmw==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@oven/bun-windows-x64": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/@oven/bun-windows-x64/-/bun-windows-x64-1.1.4.tgz", - "integrity": "sha512-1OUXrxN6NewDDlnwYJUA8qc3xoENuzXAl6NBQ4DQUzvG7sf+woidB0US4kyMU4UM00yZ30R377bHYelZBbyHBg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ] - }, - "node_modules/@oven/bun-windows-x64-baseline": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/@oven/bun-windows-x64-baseline/-/bun-windows-x64-baseline-1.1.4.tgz", - "integrity": "sha512-WREwoHUf+J7MwGcaLnlgQQcyNOkvxQhoh7dMOkF8KrkMAJdrnila8mD4qaJUFjAUwnMOVW28R6xZ23G8N4AMNQ==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ] - }, "node_modules/@pkgjs/parseargs": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", @@ -3706,36 +3601,6 @@ "semver": "^7.0.0" } }, - "node_modules/bun": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/bun/-/bun-1.1.4.tgz", - "integrity": "sha512-J78P9T2gMv2eki64AJnHjmAgSU1WuE4QPVvlYuhy/UmLClTwFaCnyoU0Rza7T5q97O4JIoGhmVCpEfI0Ri6anw==", - "cpu": [ - "arm64", - "x64" - ], - "dev": true, - "hasInstallScript": true, - "os": [ - "darwin", - "linux", - "win32" - ], - "bin": { - "bun": "bin/bun.exe", - "bunx": "bin/bun.exe" - }, - "optionalDependencies": { - "@oven/bun-darwin-aarch64": "1.1.4", - "@oven/bun-darwin-x64": "1.1.4", - "@oven/bun-darwin-x64-baseline": "1.1.4", - "@oven/bun-linux-aarch64": "1.1.4", - "@oven/bun-linux-x64": "1.1.4", - "@oven/bun-linux-x64-baseline": "1.1.4", - "@oven/bun-windows-x64": "1.1.4", - "@oven/bun-windows-x64-baseline": "1.1.4" - } - }, "node_modules/bytes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", diff --git a/package.json b/package.json index 381985dd..7573fc77 100644 --- a/package.json +++ b/package.json @@ -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", + "prepare": "src/scripts/install-hooks && test/bun-setup.sh", "prepublishOnly": "npm run build", "prettier": "prettier . --check", "test": "npm run test:unit && npm run test:e2e", @@ -80,7 +80,6 @@ "@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", diff --git a/src/index.ts b/src/index.ts index 3ef0e4bd..b83eb2ac 100755 --- a/src/index.ts +++ b/src/index.ts @@ -140,7 +140,7 @@ const install = async ( pkgsNormalized.forEach(async pkgFile => { const packageManager = await getPackageManagerForInstall(options, pkgFile) - const cmd = packageManager + (process.platform === 'win32' && packageManager !== 'bun' ? '.cmd' : '') + const cmd = packageManager + (process.platform === 'win32' ? '.cmd' : '') const cwd = options.cwd || path.resolve(pkgFile, '..') let stdout = '' try { diff --git a/src/package-managers/bun.ts b/src/package-managers/bun.ts index be840f6e..b4715a9d 100644 --- a/src/package-managers/bun.ts +++ b/src/package-managers/bun.ts @@ -1,6 +1,7 @@ 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' @@ -14,6 +15,12 @@ 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/doctor.test.ts b/test/doctor.test.ts index 024da9d6..e2729ccd 100644 --- a/test/doctor.test.ts +++ b/test/doctor.test.ts @@ -483,6 +483,7 @@ 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', () => { diff --git a/test/package-managers/bun/index.test.ts b/test/package-managers/bun/index.test.ts index 637ff9bf..a2fd263d 100644 --- a/test/package-managers/bun/index.test.ts +++ b/test/package-managers/bun/index.test.ts @@ -1,9 +1,12 @@ +import os from 'os' import * as bun from '../../../src/package-managers/bun' import chaiSetup from '../../helpers/chaiSetup' chaiSetup() -describe('bun', function () { +// Bun not yet supported on Windows +const describeSkipWindows = os.platform() === 'win32' ? describe.skip : describe +describeSkipWindows('bun', function () { it('list', async () => { const result = await bun.list({ cwd: __dirname }) result.should.have.property('ncu-test-v2')