修复依赖是否安装检查逻辑

This commit is contained in:
whyour 2025-05-23 01:14:28 +08:00
parent 1c18668bad
commit 0ff60f8cf8

View File

@ -517,15 +517,11 @@ 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__', 'inner package'))"`,
[DependenceTypes.python3]: `python3 -c "import sys, importlib.util; from importlib.metadata import version, PackageNotFoundError; m=sys.argv[1]; spec=importlib.util.find_spec(m); print(version(m) if spec and 'site-packages' in (spec.origin or '') else (m if spec else ''))" ${name}`,
[DependenceTypes.linux]: `apk info -es ${name}`,
};
let command = baseCommands[type];
return type === DependenceTypes.python3
? command
: `${command} ${name.trim()}`;
return baseCommands[type];
}
export function getInstallCommand(type: DependenceTypes, name: string): string {