-
Notifications
You must be signed in to change notification settings - Fork 9
fix: support bun old and new lockfiles #227
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,7 +6,7 @@ export type JsPackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun' | 'deno'; | |||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| type JsPackageManagerMeta = { | ||||||||||||||||||||||||||||||
| name: JsPackageManager; | ||||||||||||||||||||||||||||||
| lockfile: string; | ||||||||||||||||||||||||||||||
| lockfile: string | string[]; | ||||||||||||||||||||||||||||||
| add: string; | ||||||||||||||||||||||||||||||
| exec: string; | ||||||||||||||||||||||||||||||
| dlx: string; | ||||||||||||||||||||||||||||||
|
|
@@ -36,7 +36,7 @@ export const JS_PACKAGE_MANAGERS: Record<JsPackageManager, JsPackageManagerMeta> | |||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||
| bun: { | ||||||||||||||||||||||||||||||
| name: 'bun', | ||||||||||||||||||||||||||||||
| lockfile: 'bun.lockb', | ||||||||||||||||||||||||||||||
| lockfile: ['bun.lock', 'bun.lockb'], | ||||||||||||||||||||||||||||||
| add: 'bun add', | ||||||||||||||||||||||||||||||
| exec: 'bun run', | ||||||||||||||||||||||||||||||
| dlx: 'bunx', | ||||||||||||||||||||||||||||||
|
|
@@ -67,14 +67,30 @@ export function detectJsPackageManager(opts?: { | |||||||||||||||||||||||||||||
| let pm: JsPackageManager; | ||||||||||||||||||||||||||||||
| let detectedPm: JsPackageManager | undefined; | ||||||||||||||||||||||||||||||
| for (pm in JS_PACKAGE_MANAGERS) { | ||||||||||||||||||||||||||||||
| const lockFilePath = path.join( | ||||||||||||||||||||||||||||||
| cwd, | ||||||||||||||||||||||||||||||
| JS_PACKAGE_MANAGERS[pm].lockfile, | ||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
| const lockfiles = Array.isArray(JS_PACKAGE_MANAGERS[pm].lockfile) | ||||||||||||||||||||||||||||||
| ? JS_PACKAGE_MANAGERS[pm].lockfile | ||||||||||||||||||||||||||||||
| : [JS_PACKAGE_MANAGERS[pm].lockfile as string]; | ||||||||||||||||||||||||||||||
|
Comment on lines
+70
to
+72
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if (pathExistsSync(lockFilePath)) { | ||||||||||||||||||||||||||||||
| let lockFileExists = false; | ||||||||||||||||||||||||||||||
| for (const lockfile of lockfiles) { | ||||||||||||||||||||||||||||||
| const lockFilePath = path.join(cwd, lockfile); | ||||||||||||||||||||||||||||||
| if (pathExistsSync(lockFilePath)) { | ||||||||||||||||||||||||||||||
| lockFileExists = true; | ||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
Comment on lines
+74
to
+81
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if (lockFileExists) { | ||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||
| // if we find 2 lockfiles at the same level, we throw an error | ||||||||||||||||||||||||||||||
| if (detectedPm) throw new Error(`Found multiple js package manager lockfiles - ${JS_PACKAGE_MANAGERS[pm].lockfile} and ${JS_PACKAGE_MANAGERS[detectedPm].lockfile}`); | ||||||||||||||||||||||||||||||
| if (detectedPm) { | ||||||||||||||||||||||||||||||
| const currentLockfiles = Array.isArray(JS_PACKAGE_MANAGERS[pm].lockfile) | ||||||||||||||||||||||||||||||
| ? (JS_PACKAGE_MANAGERS[pm].lockfile as string[]).join(' or ') | ||||||||||||||||||||||||||||||
| : JS_PACKAGE_MANAGERS[pm].lockfile; | ||||||||||||||||||||||||||||||
| const detectedLockfiles = Array.isArray(JS_PACKAGE_MANAGERS[detectedPm].lockfile) | ||||||||||||||||||||||||||||||
| ? (JS_PACKAGE_MANAGERS[detectedPm].lockfile as string[]).join(' or ') | ||||||||||||||||||||||||||||||
| : JS_PACKAGE_MANAGERS[detectedPm].lockfile; | ||||||||||||||||||||||||||||||
| throw new Error(`Found multiple js package manager lockfiles - ${currentLockfiles} and ${detectedLockfiles}`); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| detectedPm = pm; | ||||||||||||||||||||||||||||||
|
Comment on lines
+85
to
94
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.