Skip to content

Commit

Permalink
Add verbose logging
Browse files Browse the repository at this point in the history
  • Loading branch information
matz3 committed Feb 25, 2020
1 parent 534f6fa commit 0e468c4
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions lib/tasks/buildThemes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const path = require("path");
const themeBuilder = require("../processors/themeBuilder");
const ReaderCollectionPrioritized = require("@ui5/fs").ReaderCollectionPrioritized;
const fsInterface = require("@ui5/fs").fsInterface;
const log = require("@ui5/logger").getLogger("builder:tasks:buildThemes");

/**
* Task to build a library theme.
Expand Down Expand Up @@ -61,18 +62,11 @@ module.exports = async function({workspace, dependencies, options}) {
let allResources = await pAllResources;

const isAvailable = function(resource) {
let themeAvailable = false;
let libraryAvailable = false;

let themeAvailable = false;
const resourcePath = resource.getPath();
const themeName = path.basename(path.dirname(resourcePath));

if (!availableThemes || availableThemes.length === 0) {
themeAvailable = true; // If no themes are found, build all themes
} else {
themeAvailable = availableThemes.includes(themeName);
}

if (!availableLibraries || availableLibraries.length === 0) {
libraryAvailable = true; // If no libraries are found, build themes for all libraries
} else {
Expand All @@ -83,11 +77,35 @@ module.exports = async function({workspace, dependencies, options}) {
}
}

// Only build if theme and library are available
return themeAvailable && libraryAvailable;
if (!availableThemes || availableThemes.length === 0) {
themeAvailable = true; // If no themes are found, build all themes
} else {
themeAvailable = availableThemes.includes(themeName);
}

if (log.isLevelEnabled("verbose")) {
if (!libraryAvailable) {
log.verbose(`Skipping ${resourcePath}: Library is not available`);
}
if (!themeAvailable) {
log.verbose(`Skipping ${resourcePath}: sap.ui.core theme '${themeName}' is not available`);
}
}

// Only build if library and theme are available
return libraryAvailable && themeAvailable;
};

if (availableLibraries || availableThemes) {
if (log.isLevelEnabled("verbose")) {
log.verbose("Filtering themes to be built:");
if (availableLibraries) {
log.verbose(`Available libraries: ${availableLibraries.join(", ")}`);
}
if (availableThemes) {
log.verbose(`Available sap.ui.core themes: ${availableThemes.join(", ")}`);
}
}
allResources = allResources.filter(isAvailable);
}

Expand Down

0 comments on commit 0e468c4

Please sign in to comment.