Skip to content

Commit 6cb38dc

Browse files
committed
Fixed resolving $app-name
1 parent f4ba4ca commit 6cb38dc

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/utils.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,16 @@ async function getNotificationDestination() {
115115
return notificationDestination;
116116
}
117117

118+
let prefix // be filled in below...
118119
function getPrefix() {
119-
let prefix = cds.env.requires.notifications?.prefix;
120-
if (prefix) {
121-
return prefix === "$app-name" ? process.env.npm_package_name : prefix;
122-
} else {
123-
return basename(cds.root);
124-
}
120+
if (!prefix) {
121+
prefix = cds.env.requires.notifications?.prefix
122+
if (prefix === "$app-name") try {
123+
prefix = require(cds.root + '/package.json').name
124+
} catch { prefix = null }
125+
if (!prefix) prefix = basename(cds.root)
126+
}
127+
return prefix
125128
}
126129

127130
function getNotificationTypesKeyWithPrefix(notificationTypeKey) {

0 commit comments

Comments
 (0)