Skip to content

Commit

Permalink
Depdency install fix: Update DependencyManager.kt to use package mana…
Browse files Browse the repository at this point in the history
…ger specific install command
  • Loading branch information
shimizu-izumi committed Jun 22, 2024
1 parent fb4047c commit fb56436
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,22 @@ class DependencyManager(private val project: Project) {
}.values.firstOrNull()
}

private fun getInstallCommand(packageManager: String): String {
return when (packageManager) {
"npm" -> "i"
"pnpm" -> "add"
"yarn" -> "add"
"bun" -> "add"
else -> throw IllegalArgumentException("Unknown package manager: $packageManager")
}
}

fun installDependencies(dependencyNames: List<String>, installationType: InstallationType = InstallationType.PROD) {
getPackageManager()?.let { packageManager ->
// install the dependency
val command = listOfNotNull(
packageManager,
"i",
getInstallCommand(packageManager),
if (installationType == InstallationType.DEV) "-D" else null,
*dependencyNames.toTypedArray()
).toTypedArray()
Expand Down

0 comments on commit fb56436

Please sign in to comment.