Skip to content

Commit ce39fac

Browse files
committed
fix
1 parent 5a684cd commit ce39fac

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

libs/backend-api7/e2e/support/global-setup.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import axios from 'axios';
22
import { spawn } from 'node:child_process';
33
import { randomUUID } from 'node:crypto';
44
import { Agent } from 'node:https';
5-
import { gte, lt } from 'semver';
5+
import * as semver from 'semver';
66

77
const httpClient = axios.create({
88
baseURL: 'https://localhost:7443',
@@ -68,7 +68,12 @@ const initUser = async (username = 'admin', password = 'admin') => {
6868
});
6969

7070
// If the version is lower than 3.2.15, the license should be activated first.
71-
if (lt('3.2.15', process.env.BACKEND_API7_VERSION ?? '0.0.0'))
71+
if (
72+
semver.lt(
73+
'3.2.15',
74+
semver.coerce(process.env.BACKEND_API7_VERSION) ?? '0.0.0',
75+
)
76+
)
7277
await activateAPI7();
7378

7479
console.log('Modify password');
@@ -88,7 +93,12 @@ const initUser = async (username = 'admin', password = 'admin') => {
8893

8994
// If the version is greater than or equal to 3.2.15, the license should
9095
// be activated after changing the password.
91-
if (gte('3.2.15', process.env.BACKEND_API7_VERSION ?? '0.0.0'))
96+
if (
97+
semver.gte(
98+
'3.2.15',
99+
semver.coerce(process.env.BACKEND_API7_VERSION) ?? '0.0.0',
100+
)
101+
)
92102
await activateAPI7();
93103
};
94104

libs/backend-api7/e2e/support/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as ADCSDK from '@api7/adc-sdk';
22
import { Listr, SilentRenderer } from 'listr2';
3+
import * as semver from 'semver';
34

45
import { BackendAPI7 } from '../../src';
56

@@ -101,7 +102,7 @@ export const conditionalDescribe = (cond: cond) =>
101102
export const conditionalIt = (cond: cond) => (cond ? it : it.skip);
102103

103104
export const semverCondition = (
104-
op: (v1: string, v2: string) => boolean,
105+
op: (v1: string, v2: string | semver.SemVer) => boolean,
105106
target: string,
106-
base = process.env.BACKEND_API7_VERSION ?? '0.0.0',
107+
base = semver.coerce(process.env.BACKEND_API7_VERSION) ?? '0.0.0',
107108
) => op(target, base);

0 commit comments

Comments
 (0)