Skip to content

Commit

Permalink
[INTERNAL] LibraryFormatter namespace detection: Add exception for SA…
Browse files Browse the repository at this point in the history
…P theme libraries

Add exceptional handling for SAP theme libraries which used to be of
type "library" (today they use "theme-library").

To allow use of OpenUI5 theme libraries in versions lower than 1.75 we
must ignore namespace.
  • Loading branch information
RandomByte committed Mar 25, 2020
1 parent 63adfd1 commit 6e4b10b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/types/library/LibraryFormatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const glob = require("globby");
const slash = require("slash");
const AbstractUi5Formatter = require("../AbstractUi5Formatter");

const SAP_THEMES_NS_WHITELIST = ["themelib_sap_fiori_3", "themelib_sap_bluecrystal", "themelib_sap_belize"];

class LibraryFormatter extends AbstractUi5Formatter {
/**
Expand All @@ -31,7 +32,20 @@ class LibraryFormatter extends AbstractUi5Formatter {
"Either no setting was provided or the path not found.");
}

project.metadata.namespace = await this.getNamespace();
try {
project.metadata.namespace = await this.getNamespace();
} catch (err) {
if (SAP_THEMES_NS_WHITELIST.includes(this._project.metadata.name)) {
// Exceptional handling for SAP theme libraries which used to be of type "library"
// (today they use "theme-library").
// To allow use of OpenUI5 theme libraries in versions lower than 1.75 we must ignore
// namespace detection errors.
log.verbose(`Ignoring failed namespace detection for whitelisted SAP theme library ` +
`${this._project.metadata.name}: ${err.message}`);
} else {
throw err;
}
}

try {
project.metadata.copyright = await this.getCopyright();
Expand Down

0 comments on commit 6e4b10b

Please sign in to comment.