mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
24 lines
831 B
TypeScript
24 lines
831 B
TypeScript
import type { PackageManager } from "../types";
|
|
|
|
/**
|
|
* Returns the appropriate command for running a package without installing it globally,
|
|
* based on the selected package manager.
|
|
*
|
|
* @param packageManager - The selected package manager (e.g., 'npm', 'yarn', 'pnpm', 'bun').
|
|
* @param commandWithArgs - The command to run, including arguments (e.g., "prisma generate --schema=./prisma/schema.prisma").
|
|
* @returns The full command string (e.g., "npx prisma generate --schema=./prisma/schema.prisma").
|
|
*/
|
|
export function getPackageExecutionCommand(
|
|
packageManager: PackageManager | null | undefined,
|
|
commandWithArgs: string,
|
|
): string {
|
|
switch (packageManager) {
|
|
case "pnpm":
|
|
return `pnpm dlx ${commandWithArgs}`;
|
|
case "bun":
|
|
return `bunx ${commandWithArgs}`;
|
|
default:
|
|
return `npx ${commandWithArgs}`;
|
|
}
|
|
}
|