Skip to content

Commit

Permalink
feat: add additionalArgs by agent (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
ntnyq authored Nov 27, 2024
1 parent 9bdb2b7 commit 2763b50
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface InstallPackageOptions {
silent?: boolean
packageManager?: string
preferOffline?: boolean
additionalArgs?: string[]
additionalArgs?: string[] | ((agent: string, detectedAgent: string) => string[] | undefined)
}

export async function installPackage(names: string | string[], options: InstallPackageOptions = {}) {
Expand All @@ -20,7 +20,9 @@ export async function installPackage(names: string | string[], options: InstallP
if (!Array.isArray(names))
names = [names]

const args = options.additionalArgs || []
const args = (typeof options.additionalArgs === 'function'
? options.additionalArgs(agent, detectedAgent)
: options.additionalArgs) || []

if (options.preferOffline) {
// yarn berry uses --cached option instead of --prefer-offline
Expand Down

0 comments on commit 2763b50

Please sign in to comment.