@sasjs/cli
Version:
Command line interface for SASjs
27 lines (26 loc) • 1.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.updateLinkTag = void 0;
var updateLinkTag = function (linkTag, assetPathMap, tagType) {
if (tagType === void 0) { tagType = 'link'; }
var linkSourcePath = tagType === 'link'
? linkTag.getAttribute('href')
: linkTag.getAttribute('src');
if (!linkSourcePath)
return;
var isUrl = linkSourcePath.startsWith('http') || linkSourcePath.startsWith('//');
if (isUrl)
return;
var assetPath = assetPathMap.find(function (entry) {
return entry.source === linkSourcePath ||
"./".concat(entry.source) === linkSourcePath ||
"/".concat(entry.source) === linkSourcePath;
});
if (!(assetPath === null || assetPath === void 0 ? void 0 : assetPath.target)) {
throw new Error("Unable to find file: ".concat(linkSourcePath));
}
tagType === 'link'
? linkTag.setAttribute('href', assetPath.target)
: linkTag.setAttribute('src', assetPath.target);
};
exports.updateLinkTag = updateLinkTag;