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

feat: add additionalArgs by agent #20

Merged
Merged
Changes from all 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: 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