-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcds-plugin.js
More file actions
23 lines (19 loc) · 838 Bytes
/
cds-plugin.js
File metadata and controls
23 lines (19 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const cds = require("@sap/cds/lib");
if (cds.cli.command === "build") {
// register build plugin
cds.build?.register?.('notifications', require("./lib/build"));
}
else cds.once("served", async () => {
const { validateNotificationTypes, readFile } = require("./lib/utils");
const { createNotificationTypesMap } = require("./lib/notificationTypes");
const production = cds.env.profiles?.includes("production");
// read notification types
const notificationTypes = readFile(cds.env.requires?.notifications?.types);
if (validateNotificationTypes(notificationTypes)) {
if (!production) {
const notificationTypesMap = createNotificationTypesMap(notificationTypes, true);
cds.notifications = { local: { types: notificationTypesMap } };
}
}
require("@sap-cloud-sdk/util").setGlobalLogLevel("error")
})