Skip to content

Commit 61e65ff

Browse files
authored
fix(cds-plugin-ui5): coerce versions for satisfy check (#1303)
1 parent 01ced07 commit 61e65ff

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/cds-plugin-ui5/cds-plugin.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ if (!skip) {
297297
// check if the register function for build tasks is available at the cds object
298298
// and if the Plugin class is available to register the cds build task to cover
299299
// the tracks of the cds-plugin-ui5 workspace configuration and dependencies
300-
const { minVersion, satisfies } = require("semver");
300+
const { minVersion, satisfies, coerce } = require("semver");
301301
if (typeof cds.build?.register === "function" && typeof cds.build?.Plugin?.constructor === "function") {
302302
const { readFile, writeFile } = require("fs").promises;
303303
const { existsSync } = require("fs");
@@ -333,12 +333,14 @@ if (!skip) {
333333
}
334334
init() {}
335335
clean() {
336-
if (!satisfies(cdsdkVersion, ">=8")) {
336+
// allowed ranges for CDSDK >= 8 are -1024..-1 and 512..1024
337+
if (!satisfies(coerce(cdsdkVersion), ">=8")) {
337338
this._priority = -1; // hack to ensure that the task is executed last!
338339
}
339340
}
340341
get priority() {
341-
if (!satisfies(cdsdkVersion, ">=8")) {
342+
// allowed ranges for CDSDK >= 8 are -1024..-1 and 512..1024
343+
if (!satisfies(coerce(cdsdkVersion), ">=8")) {
342344
return this._priority || 1;
343345
} else {
344346
return -1;
@@ -390,7 +392,7 @@ if (!skip) {
390392
},
391393
);
392394
} else {
393-
if (!satisfies(cdsdkVersion, ">=7.5.0")) {
395+
if (!satisfies(coerce(cdsdkVersion), ">=7.5.0")) {
394396
// TODO: add error message to inform the user that the cds build task is not available
395397
// and that the @sap/cds-dk version is too old to support the cds build task
396398
LOG.warn(`The cds build task requires @sap/cds-dk version >= 7.5.0! Skipping execution as your @sap/cds-dk version ${cdsdkVersion} is too old...`);

0 commit comments

Comments
 (0)