From 16a428431d2f7cc40447bf68a6c05436d889d3ab Mon Sep 17 00:00:00 2001 From: hheli Date: Sat, 16 May 2026 08:41:09 +0800 Subject: [PATCH] fix(files-widget): use 'where' instead of 'which' on Windows for dep detection 'which' is a Unix command not available in cmd.exe, which Node.js uses as the default shell on Windows. When running pi from PowerShell or cmd.exe, 'execSync(`which ${cmd}`)' always fails, causing the startup dependency check to report bat, delta, and glow as missing even when they are installed and on PATH. Use 'where' on Windows (the platform-native equivalent) and keep 'which' on other platforms. Fixes dependency detection for Windows users of /readfiles. --- files-widget/CHANGELOG.md | 3 +++ files-widget/utils.ts | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/files-widget/CHANGELOG.md b/files-widget/CHANGELOG.md index 958032e..4b7f583 100644 --- a/files-widget/CHANGELOG.md +++ b/files-widget/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to this extension will be documented in this file. ## [Unreleased] +### Fixed +- Use `where` instead of `which` on Windows to detect `bat`, `delta`, and `glow`, so the dependency check works when running from PowerShell or cmd.exe. + ## [0.1.21] - 2026-05-07 ### Changed diff --git a/files-widget/utils.ts b/files-widget/utils.ts index 009cc90..04eca7c 100644 --- a/files-widget/utils.ts +++ b/files-widget/utils.ts @@ -2,7 +2,8 @@ import { execSync } from "node:child_process"; export function hasCommand(cmd: string): boolean { try { - execSync(`which ${cmd}`, { stdio: "ignore" }); + const checkCmd = process.platform === "win32" ? "where" : "which"; + execSync(`${checkCmd} ${cmd}`, { stdio: "ignore" }); return true; } catch { return false;