
- Added a version check for the devchat-ask package in commands.ts. - Updated appInstall function in app_install.ts to accept package version. - Modified installAskCode function in install_askcode.ts to pass package version to appInstall. - Updated installDevchat function in install_devchat.ts to pass empty string as package version to appInstall. - Added a new utility function getPackageVersion in pip_package_version.ts to get the installed version of a package.
13 lines
499 B
TypeScript
13 lines
499 B
TypeScript
import { execSync } from 'child_process';
|
|
|
|
export function getPackageVersion(pythonPath: string, packageName: string): string | undefined {
|
|
try {
|
|
const stdout = execSync(`${pythonPath} -m pip show ${packageName}`).toString();
|
|
const versionLine = stdout.split('\n').find(line => line.startsWith('Version'));
|
|
return versionLine ? versionLine.split(': ')[1] : undefined;
|
|
} catch (error) {
|
|
console.error(`exec error: ${error}`);
|
|
return undefined;
|
|
}
|
|
}
|