Skip to content

Commit

Permalink
Fix/cds 7 3 0 breaking api (#32)
Browse files Browse the repository at this point in the history
* upgrade deps

* add version check and change cds plugin export appropriately

* export promise instead of function

* re-order
  • Loading branch information
rlindner81 authored Oct 18, 2023
1 parent 86aac28 commit 198101c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 11 additions & 3 deletions cds-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"use strict";

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

const activate = async () => {
Expand All @@ -27,6 +28,13 @@ const activate = async () => {
}
};

module.exports = {
activate,
};
// NOTE: for sap/cds < 7.3.0 it was expected to export activate as function property, otherwise export the promise of
// running activate
const doExportActivateAsProperty =
cdsPackage.version.localeCompare("7.3.0", undefined, { numeric: true, sensitivity: "base" }) < 0;

module.exports = doExportActivateAsProperty
? {
activate,
}
: activate();
4 changes: 2 additions & 2 deletions example-cap-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
},
"dependencies": {
"@cap-js-community/feature-toggle-library": "*",
"@sap/cds": "^7.2.0",
"@sap/cds": "^7.3.0",
"express": "^4.18.2"
},
"devDependencies": {
"@sap/cds-dk": "^7.2.0"
"@sap/cds-dk": "^7.3.0"
},
"cds": {
"featureToggles": {
Expand Down

0 comments on commit 198101c

Please sign in to comment.