修复查询 python 依赖存在逻辑

This commit is contained in:
whyour
2025-05-21 01:25:24 +08:00
parent eb1c00984c
commit f94582b68d
3 changed files with 17 additions and 15 deletions
+14
View File
@@ -514,6 +514,20 @@ export async function setSystemTimezone(timezone: string): Promise<boolean> {
}
}
export function getGetCommand(type: DependenceTypes, name: string): string {
const baseCommands = {
[DependenceTypes.nodejs]: `pnpm ls -g | grep "${name}" | head -1`,
[DependenceTypes.python3]: `python3 -c "import importlib;pkg=importlib.import_module('${name}');print(getattr(pkg, '__version__', 'version not found'))"`,
[DependenceTypes.linux]: `apk info -es ${name}`,
};
let command = baseCommands[type];
return type === DependenceTypes.python3
? command
: `${command} ${name.trim()}`;
}
export function getInstallCommand(type: DependenceTypes, name: string): string {
const baseCommands = {
[DependenceTypes.nodejs]: 'pnpm add -g',