(pkgManager: PackageManager, projectDir: string)
| 31 | } |
| 32 | |
| 33 | const runInstallCommand = async (pkgManager: PackageManager, projectDir: string): Promise<Ora | null> => { |
| 34 | switch (pkgManager) { |
| 35 | // When using npm, inherit the stderr stream so that the progress bar is shown |
| 36 | case "npm": |
| 37 | await execa(pkgManager, ["install"], { |
| 38 | cwd: projectDir, |
| 39 | stderr: "inherit", |
| 40 | }) |
| 41 | |
| 42 | return null |
| 43 | |
| 44 | // When using yarn or pnpm, use the stdout stream and ora spinner to show the progress |
| 45 | case "pnpm": |
| 46 | return execWithSpinner(projectDir, pkgManager, { |
| 47 | onDataHandle: (spinner) => (data) => { |
| 48 | const text = data.toString() |
| 49 | |
| 50 | if (text.includes("Progress")) { |
| 51 | spinner.text = text.includes("|") ? (text.split(" | ")[1] ?? "") : text |
| 52 | } |
| 53 | }, |
| 54 | }) |
| 55 | |
| 56 | case "yarn": |
| 57 | return execWithSpinner(projectDir, pkgManager, { |
| 58 | onDataHandle: (spinner) => (data) => { |
| 59 | spinner.text = data.toString() |
| 60 | }, |
| 61 | }) |
| 62 | |
| 63 | // When using bun, the stdout stream is ignored and the spinner is shown |
| 64 | case "bun": |
| 65 | return execWithSpinner(projectDir, pkgManager, { stdout: "ignore" }) |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | export const installDependencies = async ({ projectDir }: { projectDir: string }) => { |
| 70 | logger.info("Installing dependencies...") |
no test coverage detected