mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
refractor: organize files
This commit is contained in:
23
apps/cli/src/utils/package-runner.ts
Normal file
23
apps/cli/src/utils/package-runner.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
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}`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user