Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions server/routes/taskmaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ const router = express.Router();
*/
async function checkTaskMasterInstallation() {
return new Promise((resolve) => {
// Check if task-master command is available
const child = spawn('which', ['task-master'], {
// Check if task-master command is available ('which' is not available in cmd.exe)
const whichCommand = process.platform === 'win32' ? 'where' : 'which';
const child = spawn(whichCommand, ['task-master'], {
stdio: ['ignore', 'pipe', 'pipe'],
shell: true
});
Expand All @@ -59,6 +60,8 @@ async function checkTaskMasterInstallation() {

child.on('close', (code) => {
if (code === 0 && output.trim()) {
// 'where' may return multiple matches (e.g. task-master and task-master.cmd)
const installPath = output.trim().split(/\r?\n/)[0];
// TaskMaster is installed, get version
const versionChild = spawn('task-master', ['--version'], {
stdio: ['ignore', 'pipe', 'pipe'],
Expand All @@ -74,16 +77,16 @@ async function checkTaskMasterInstallation() {
versionChild.on('close', (versionCode) => {
resolve({
isInstalled: true,
installPath: output.trim(),
installPath,
version: versionCode === 0 ? versionOutput.trim() : 'unknown',
reason: null
});
});

versionChild.on('error', () => {
resolve({
isInstalled: true,
installPath: output.trim(),
installPath,
version: 'unknown',
reason: null
});
Expand Down