Skip to content

Commit 1204179

Browse files
committed
chore: replace $ api bun to execa
1 parent b3e717a commit 1204179

1 file changed

Lines changed: 32 additions & 43 deletions

File tree

src/core/taskmaster/TaskMaster.ts

Lines changed: 32 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* libs */
2-
import { $ } from "bun";
32
import { oraPromise } from "ora";
4-
import { mkdir } from "node:fs/promises";
3+
import { mkdir, writeFile } from "node:fs/promises";
4+
import { execa } from "execa";
55
import inquirer from "inquirer";
66
import path from "node:path";
77
import chalk from "chalk";
@@ -13,7 +13,6 @@ import { DEV_MODE } from "@/constants";
1313
import { existsAsync } from "@/utils/extras";
1414

1515
/* types */
16-
1716
import type { T_PackageManager } from "@/@types/index";
1817

1918
// ===============================
@@ -58,41 +57,32 @@ export class TaskMaster {
5857
)}.`,
5958
};
6059

61-
await oraPromise(
62-
(async () => {
63-
let cmd: string[] = [];
64-
let args: string[] = [];
65-
66-
switch (packageManagerChoice) {
67-
case "npm":
68-
cmd = ["npm"];
69-
args = ["install", "-g", "task-master-ai@latest"];
70-
break;
71-
case "pnpm":
72-
cmd = ["pnpm"];
73-
args = ["add", "-g", "task-master-ai@latest"];
74-
break;
75-
case "bun":
76-
cmd = [process.execPath];
77-
args = ["add", "-g", "task-master-ai@latest"];
78-
break;
79-
}
80-
81-
const proc = Bun.spawn([...cmd, ...args], {
82-
stdout: "inherit",
83-
stderr: "inherit",
84-
env: process.env,
85-
});
86-
87-
await proc.exited;
88-
if (proc.exitCode !== 0) {
89-
throw new Error(
90-
`Installation failed with exit code ${proc.exitCode}`,
91-
);
92-
}
93-
})(),
94-
oraOptions,
95-
);
60+
await oraPromise(async () => {
61+
let command: string;
62+
let args: string[] = [];
63+
64+
switch (packageManagerChoice) {
65+
case "npm":
66+
command = "npm";
67+
args = ["install", "-g", "task-master-ai@latest"];
68+
break;
69+
case "pnpm":
70+
command = "pnpm";
71+
args = ["add", "-g", "task-master-ai@latest"];
72+
break;
73+
case "bun":
74+
command = "bun";
75+
args = ["add", "-g", "task-master-ai@latest"];
76+
break;
77+
default:
78+
throw new Error("Invalid package manager");
79+
}
80+
81+
await execa(command, args, {
82+
stdio: "inherit",
83+
env: process.env,
84+
});
85+
}, oraOptions);
9686
}
9787

9888
/**
@@ -105,15 +95,14 @@ export class TaskMaster {
10595

10696
if (await existsAsync(prdFilePath)) {
10797
console.log(chalk.yellow(`PRD file already exists at ${prdFilePath}.`));
108-
await $`task-master init`;
98+
await execa("task-master", ["init"], { stdio: "inherit" });
10999
}
110100

111101
try {
112102
await oraPromise(
113103
async () => {
114104
await mkdir(prdDestination, { recursive: true });
115-
const file = Bun.file(prdFilePath);
116-
await Bun.write(file, "");
105+
await writeFile(prdFilePath, "");
117106
},
118107
{
119108
text: "Generating PRD file ...",
@@ -128,13 +117,13 @@ export class TaskMaster {
128117
throw error;
129118
}
130119

131-
await $`task-master init`;
120+
await execa("task-master", ["init"], { stdio: "inherit" });
132121
}
133122

134123
/**
135124
* @description - Configures the AI models for task-master AI
136125
*/
137126
async configAsync() {
138-
await $`task-master models --setup`;
127+
await execa("task-master", ["models", "--setup"], { stdio: "inherit" });
139128
}
140129
}

0 commit comments

Comments
 (0)