Improve DevChat dependency check and error handling

- Add logger import to commandsBase.ts.
- Replace plain error handling with logger in checkDevChatDependency.
- Refactor getPipxEnvironmentPath and updateEnvironmentPath functions.
This commit is contained in:
bobo.yang 2023-06-12 08:39:02 +08:00
parent 857f73a4d9
commit 13f161506f

View File

@ -1,6 +1,7 @@
// src/contributes/commandsBase.ts
import { runCommand } from "../util/commonUtil";
import { logger } from "../util/logger";
export function checkDevChatDependency(): boolean {
@ -14,10 +15,15 @@ export function checkDevChatDependency(): boolean {
runCommand('devchat --help');
return true;
} else {
logger.channel()?.error(`Failed to get pipx environment path, I will try to install pipx.`);
logger.channel()?.show();
return false;
}
} catch (error) {
// DevChat dependency check failed
// log out detail error message
logger.channel()?.error(`Failed to check DevChat dependency: ${error}`);
logger.channel()?.show();
return false;
}
}