Merge pull request #179 from covespace/log_devchat_fail_reason
Log devchat fail reason
This commit is contained in:
commit
427f27c97a
@ -1,42 +1,48 @@
|
|||||||
// src/contributes/commandsBase.ts
|
// src/contributes/commandsBase.ts
|
||||||
|
|
||||||
import { runCommand } from "../util/commonUtil";
|
import { runCommand } from "../util/commonUtil";
|
||||||
|
import { logger } from "../util/logger";
|
||||||
|
|
||||||
|
|
||||||
export function checkDevChatDependency(): boolean {
|
export function checkDevChatDependency(): boolean {
|
||||||
try {
|
try {
|
||||||
const binPath = getPipxEnvironmentPath();
|
const binPath = getPipxEnvironmentPath();
|
||||||
|
|
||||||
if (binPath) {
|
if (binPath) {
|
||||||
updateEnvironmentPath(binPath);
|
updateEnvironmentPath(binPath);
|
||||||
|
|
||||||
// Check if DevChat is installed
|
// Check if DevChat is installed
|
||||||
runCommand('devchat --help');
|
runCommand('devchat --help');
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
logger.channel()?.error(`Failed to get pipx environment path, I will try to install pipx.`);
|
||||||
}
|
logger.channel()?.show();
|
||||||
} catch (error) {
|
return false;
|
||||||
// DevChat dependency check failed
|
}
|
||||||
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPipxEnvironmentPath(): string | null {
|
export function getPipxEnvironmentPath(): string | null {
|
||||||
// Get pipx environment
|
// Get pipx environment
|
||||||
const pipxEnvOutput = runCommand('python3 -m pipx environment').toString();
|
const pipxEnvOutput = runCommand('python3 -m pipx environment').toString();
|
||||||
const binPathRegex = /PIPX_BIN_DIR=\s*(.*)/;
|
const binPathRegex = /PIPX_BIN_DIR=\s*(.*)/;
|
||||||
|
|
||||||
// Get BIN path from pipx environment
|
// Get BIN path from pipx environment
|
||||||
const match = pipxEnvOutput.match(binPathRegex);
|
const match = pipxEnvOutput.match(binPathRegex);
|
||||||
if (match && match[1]) {
|
if (match && match[1]) {
|
||||||
return match[1];
|
return match[1];
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateEnvironmentPath(binPath: string): void {
|
function updateEnvironmentPath(binPath: string): void {
|
||||||
// Add BIN path to PATH
|
// Add BIN path to PATH
|
||||||
process.env.PATH = `${binPath}:${process.env.PATH}`;
|
process.env.PATH = `${binPath}:${process.env.PATH}`;
|
||||||
}
|
}
|
@ -62,7 +62,7 @@ export async function dependencyCheck(): Promise<[string, string]> {
|
|||||||
}
|
}
|
||||||
if (devchatStatus === 'not ready') {
|
if (devchatStatus === 'not ready') {
|
||||||
// auto install devchat
|
// auto install devchat
|
||||||
UiUtilWrapper.runTerminal('DevChat Install', `python ${UiUtilWrapper.extensionPath() + "/tools/install.py"}`);
|
UiUtilWrapper.runTerminal('DevChat Install', `python3 ${UiUtilWrapper.extensionPath() + "/tools/install.py"}`);
|
||||||
devchatStatus = 'waiting install devchat';
|
devchatStatus = 'waiting install devchat';
|
||||||
isVersionChangeCompare = true;
|
isVersionChangeCompare = true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user