Skip to content

Commit 198101c

Browse files
authored
Fix/cds 7 3 0 breaking api (#32)
* upgrade deps * add version check and change cds plugin export appropriately * export promise instead of function * re-order
1 parent 86aac28 commit 198101c

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

cds-plugin.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"use strict";
33

44
const cds = require("@sap/cds");
5+
const cdsPackage = require("@sap/cds/package.json");
56
const { initializeFeatures } = require("./src/singleton");
67

78
const activate = async () => {
@@ -27,6 +28,13 @@ const activate = async () => {
2728
}
2829
};
2930

30-
module.exports = {
31-
activate,
32-
};
31+
// NOTE: for sap/cds < 7.3.0 it was expected to export activate as function property, otherwise export the promise of
32+
// running activate
33+
const doExportActivateAsProperty =
34+
cdsPackage.version.localeCompare("7.3.0", undefined, { numeric: true, sensitivity: "base" }) < 0;
35+
36+
module.exports = doExportActivateAsProperty
37+
? {
38+
activate,
39+
}
40+
: activate();

example-cap-server/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
},
2121
"dependencies": {
2222
"@cap-js-community/feature-toggle-library": "*",
23-
"@sap/cds": "^7.2.0",
23+
"@sap/cds": "^7.3.0",
2424
"express": "^4.18.2"
2525
},
2626
"devDependencies": {
27-
"@sap/cds-dk": "^7.2.0"
27+
"@sap/cds-dk": "^7.3.0"
2828
},
2929
"cds": {
3030
"featureToggles": {

0 commit comments

Comments
 (0)