Skip to content

Commit

Permalink
fix(ui5-task-cachebuster): support new resource-roots config option (#…
Browse files Browse the repository at this point in the history
…1166)

Fixes #1165
  • Loading branch information
petermuessig authored Feb 6, 2025
1 parent 5375d76 commit 54215b5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/ui5-task-cachebuster/lib/cachebuster.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ module.exports = async function ({ workspace, /* dependencies,*/ taskUtil, optio
.getString()
.then((content) => {
//TODO also for data-sap-ui-theme-roots ??
const sRegex = /data-sap-ui-resourceroots[\s]*=[\s]*'(.*?)'/is;
const sRegex = /(data-sap-ui-resource-?roots)[\s]*=[\s]*'(.*?)'/is;
const mParts = content.match(sRegex);
const sResourceRoots = mParts?.[1]; //captureGroup at index 1 in match result
const sResourceRoots = mParts?.[2]; //captureGroup at index 2 in match result
if (sResourceRoots) {
var oResouceRoots = JSON.parse(sResourceRoots);
const aModuleNames = Object.keys(oResouceRoots);
Expand All @@ -46,7 +46,7 @@ module.exports = async function ({ workspace, /* dependencies,*/ taskUtil, optio
oResouceRoots[sModuleName] = sModulePath;
});

var changed = content.replace(sRegex, `data-sap-ui-resourceroots='${JSON.stringify(oResouceRoots)}'`);
var changed = content.replace(sRegex, `${mParts[1]}='${JSON.stringify(oResouceRoots)}'`);
indexResource.setString(changed);
return workspace.write(indexResource);
}
Expand Down Expand Up @@ -88,7 +88,7 @@ module.exports = async function ({ workspace, /* dependencies,*/ taskUtil, optio
isDebug && console.log(`moved: ${copy.getPath()}`);
});
});
})
}),
);
})
.catch((e) => {
Expand Down

0 comments on commit 54215b5

Please sign in to comment.