Skip to content

Commit

Permalink
Simplify plugin detection again
Browse files Browse the repository at this point in the history
  • Loading branch information
oklemenz2 committed Nov 17, 2023
1 parent 0f13e86 commit 686ab57
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 42 deletions.
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Fixed

- Support union queries as parameterized views
- Fix plugin project root
- Failsafe plugin detection
- Add pull request target workflow
- Add pull request for external contributions
- Simplify plugin detection again

## Version 1.11.8 - 2023-10-24

Expand Down
21 changes: 1 addition & 20 deletions cds-plugin.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,9 @@
"use strict";

const cds = require("@sap/cds");
const path = require("path");

const cov2ap = require("./src");

const PLUGIN = "@cap-js-community/odata-v2-adapter";
const PLUGIN_CONFIG = [PLUGIN, `${PLUGIN}/cds-plugin`, `${PLUGIN}/cds-plugin.js`];

let pluginActive = cds.env.cov2ap && cds.env.cov2ap.plugin;
if (!pluginActive) {
try {
const packageJSON = require(path.join(cds.root, "package.json"));
pluginActive =
packageJSON &&
packageJSON.cds &&
packageJSON.cds.plugins &&
!!packageJSON.cds.plugins.find((plugin) => PLUGIN_CONFIG.includes(plugin) || PLUGIN_CONFIG.includes(plugin.impl));
} catch (e) {
// ignore
}
}

if (pluginActive) {
if (cds.env.cov2ap && cds.env.cov2ap.plugin) {
cds.on("bootstrap", async (app) => {
app.use(cov2ap());
});
Expand Down
41 changes: 22 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 686ab57

Please sign in to comment.