diff --git a/server/routes/taskmaster.js b/server/routes/taskmaster.js index 01a8d80100..5d899d5825 100644 --- a/server/routes/taskmaster.js +++ b/server/routes/taskmaster.js @@ -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 }); @@ -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'], @@ -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 });