mirror of
https://github.com/whyour/qinglong.git
synced 2025-07-07 11:56:08 +08:00
修复依赖是否已经安装判断
This commit is contained in:
parent
373b8c97d7
commit
665c344ae4
|
@ -48,7 +48,7 @@ export enum InstallDependenceCommandTypes {
|
||||||
|
|
||||||
export enum GetDependenceCommandTypes {
|
export enum GetDependenceCommandTypes {
|
||||||
'pnpm ls -g ',
|
'pnpm ls -g ',
|
||||||
'pip3 list --disable-pip-version-check',
|
'pip3 show --disable-pip-version-check',
|
||||||
'apk info',
|
'apk info',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ export default class DependenceService {
|
||||||
constructor(
|
constructor(
|
||||||
@Inject('logger') private logger: winston.Logger,
|
@Inject('logger') private logger: winston.Logger,
|
||||||
private sockService: SockService,
|
private sockService: SockService,
|
||||||
) {}
|
) { }
|
||||||
|
|
||||||
public async create(payloads: Dependence[]): Promise<Dependence[]> {
|
public async create(payloads: Dependence[]): Promise<Dependence[]> {
|
||||||
const tabs = payloads.map((x) => {
|
const tabs = payloads.map((x) => {
|
||||||
|
@ -191,16 +191,27 @@ export default class DependenceService {
|
||||||
if (isInstall) {
|
if (isInstall) {
|
||||||
const getCommandPrefix = GetDependenceCommandTypes[dependency.type];
|
const getCommandPrefix = GetDependenceCommandTypes[dependency.type];
|
||||||
const depVersionStr = versionDependenceCommandTypes[dependency.type];
|
const depVersionStr = versionDependenceCommandTypes[dependency.type];
|
||||||
const [_depName] = dependency.name.trim().split(depVersionStr);
|
const [_depName, _depVersion] = dependency.name
|
||||||
|
.trim()
|
||||||
|
.split(depVersionStr);
|
||||||
|
const isNodeDependence = dependency.type === DependenceTypes.nodejs;
|
||||||
|
const isLinuxDependence = dependency.type === DependenceTypes.linux;
|
||||||
|
const isPythonDependence = dependency.type === DependenceTypes.python3;
|
||||||
const depInfo = (
|
const depInfo = (
|
||||||
await promiseExecSuccess(
|
await promiseExecSuccess(
|
||||||
dependency.type === DependenceTypes.linux
|
isNodeDependence
|
||||||
? `${getCommandPrefix} ${_depName}`
|
? `${getCommandPrefix} | grep "${_depName}" | head -1`
|
||||||
: `${getCommandPrefix} | grep "${_depName}"`,
|
: `${getCommandPrefix} ${_depName}`,
|
||||||
)
|
)
|
||||||
).replace(/\s{2,}/, ' ');
|
).replace(/\s{2,}/, ' ');
|
||||||
|
|
||||||
if (depInfo) {
|
if (
|
||||||
|
depInfo &&
|
||||||
|
((isNodeDependence && depInfo.split(' ')?.[0] === _depName) ||
|
||||||
|
(isLinuxDependence && depInfo.toLocaleLowerCase().includes('installed')) ||
|
||||||
|
isPythonDependence) &&
|
||||||
|
(!_depVersion || depInfo.includes(_depVersion))
|
||||||
|
) {
|
||||||
const endTime = dayjs();
|
const endTime = dayjs();
|
||||||
const _message = `检测到已经安装 ${_depName}\n\n${depInfo}\n跳过安装\n\n依赖${actionText}成功,结束时间 ${endTime.format(
|
const _message = `检测到已经安装 ${_depName}\n\n${depInfo}\n跳过安装\n\n依赖${actionText}成功,结束时间 ${endTime.format(
|
||||||
'YYYY-MM-DD HH:mm:ss',
|
'YYYY-MM-DD HH:mm:ss',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user