Skip to content

Commit

Permalink
fix: add unknown package manager callback (#6)
Browse files Browse the repository at this point in the history
* fix: add unknown package manager callback

* chore: update unknown pm callback hint

* chore: rename callback
  • Loading branch information
userquin authored Aug 12, 2024
1 parent 851333a commit 73ad75e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ import { AGENTS, LOCKS } from './agents'

export interface DetectOptions {
cwd?: string
/**
* Callback when unknown package manager from package.json.
*
* @param packageManager - The `packageManager` value from package.json file.
*/
onUnknown?: (packageManager: string) => void
}

export type { Agent }
export { AGENTS, LOCKS }

export async function detect({ cwd }: DetectOptions = {}) {
export async function detect({ cwd, onUnknown }: DetectOptions = {}) {
let agent: Agent | undefined
let version: string | undefined

Expand Down Expand Up @@ -42,6 +48,9 @@ export async function detect({ cwd }: DetectOptions = {}) {
else if (AGENTS.includes(name)) {
agent = name
}
else {
onUnknown?.(pkg.packageManager)
}
}
}
catch {}
Expand Down

0 comments on commit 73ad75e

Please sign in to comment.