-
-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0857348
commit f7140cd
Showing
8 changed files
with
289 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { kitPnpmPath } from "../../core/resolvers.js" | ||
|
||
export async function createPackageManagerCommand( | ||
command: "i" | "un", | ||
packageNames: string[] | ||
) { | ||
let isYarn = await isFile(kenvPath("yarn.lock")) | ||
|
||
let packageManager = isYarn ? "yarn" : "pnpm" | ||
let toolCommand = command as | ||
| "add" | ||
| "i" | ||
| "remove" | ||
| "uninstall" | ||
|
||
if (isYarn) { | ||
if (command == "i") toolCommand = "add" | ||
} | ||
|
||
// Add .cmd extension for Windows | ||
if (global.isWin) { | ||
packageManager += ".cmd" | ||
} | ||
|
||
if (!isYarn) { | ||
packageManager = kitPnpmPath(packageManager) | ||
} | ||
|
||
// Combine package manager and command | ||
let installCommand = `${packageManager} ${command}` | ||
|
||
let packages = packageNames.join(" ") | ||
let fullCommand = | ||
`${installCommand} -D ${packages}`.trim() | ||
|
||
return fullCommand | ||
} |
Oops, something went wrong.