Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Bun #41

Merged
merged 5 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
uses: pnpm/action-setup@v3
with:
version: 9
- name: Install Bun
uses: oven-sh/setup-bun@v1
- name: Install Node.js
uses: actions/setup-node@v4
with:
Expand All @@ -43,6 +45,8 @@ jobs:
uses: pnpm/action-setup@v3
with:
version: 9
- name: Install Bun
uses: oven-sh/setup-bun@v1
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
Expand All @@ -67,6 +71,8 @@ jobs:
uses: pnpm/action-setup@v3
with:
version: 7
- name: Install Bun
uses: oven-sh/setup-bun@v1
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
Expand Down
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ function detectLockfile() {
let lockfileShrinkwrap = join(packageDir, 'npm-shrinkwrap.json')
let lockfileYarn = join(packageDir, 'yarn.lock')
let lockfilePnpm = join(packageDir, 'pnpm-lock.yaml')
let lockfileBun = join(packageDir, 'bun.lockb')

if (existsSync(lockfilePnpm)) {
return { file: lockfilePnpm, mode: 'pnpm' }
} else if (existsSync(lockfileBun)) {
return { file: lockfileBun, mode: 'bun' }
} else if (existsSync(lockfileNpm)) {
return { file: lockfileNpm, mode: 'npm' }
} else if (existsSync(lockfileYarn)) {
Expand Down Expand Up @@ -287,6 +290,8 @@ module.exports = function updateDB(print = defaultPrint) {
updateWith(print, yarnCommand + ' up -R caniuse-lite')
} else if (lock.mode === 'pnpm') {
updateWith(print, 'pnpm up caniuse-lite')
} else if (lock.mode === 'bun') {
updateWith(print, 'bun update caniuse-lite')
} else {
updatePackageManually(print, lock, latest)
}
Expand Down
Binary file added test/fixtures/update-bun/bun.lockb
Binary file not shown.
7 changes: 7 additions & 0 deletions test/fixtures/update-bun/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"devDependencies": {
"autoprefixer": "^9.7.4",
"postcss-preset-env": "^6.7.0",
"qs": "^6.6.0"
}
}
14 changes: 14 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,18 @@ test('updates caniuse-lite for pnpm', async () => {
)
})

test('updates caniuse-lite for bun', async () => {
await chdir('update-bun', 'package.json', 'bun.lockb')
match(
runUpdate(),
`Latest version: ${caniuse.version}\n` +
'Updating caniuse-lite version\n' +
'$ bun update caniuse-lite\n' +
'caniuse-lite has been successfully updated\n'
)

let pmls = execSync('bun pm ls --all', { env: { ...process.env, NO_COLOR: "1", FORCE_COLOR: "0" } }).toString()
kytta marked this conversation as resolved.
Show resolved Hide resolved
ok(pmls.includes(`caniuse-lite@${caniuse.version}`))
})

test.run()
Loading