@financial-times/o-assets
Version:
_Deprecated._ `o-assets` does not support Origami components delivered via npm or version 2 of the Origami specification.
70 lines (56 loc) • 1.37 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.setGlobalPathPrefix = setGlobalPathPrefix;
exports.setModuleVersions = setModuleVersions;
exports.setModulePaths = setModulePaths;
exports.resolve = resolve;
exports.default = void 0;
var globalPrefix = '/bower_components/';
var moduleVersions = {};
var modulePaths = {};
function trim(s) {
return s.replace(/^\/+/, '').replace(/\/+$/, '');
}
function setGlobalPathPrefix(newprefix) {
if (typeof newprefix !== 'undefined') {
globalPrefix = newprefix;
}
return this;
} // left in for backwards compatibility but shouldn't be needed hereonin
function setModuleVersions(map) {
for (var i in map) {
if (i) {
moduleVersions[i] = trim(map[i]);
}
}
return this;
}
function setModulePaths(map) {
for (var i in map) {
if (i) {
modulePaths[i] = trim(map[i]);
}
}
return this;
}
function resolve(path, modulename) {
var fullpath = trim(path);
if (typeof modulePaths[modulename] !== 'undefined') {
fullpath = modulePaths[modulename] + '/' + fullpath;
} else {
fullpath = modulename + '/' + fullpath;
if (globalPrefix) {
fullpath = globalPrefix + fullpath;
}
}
return fullpath;
}
var _default = {
setGlobalPathPrefix,
setModuleVersions,
setModulePaths,
resolve
};
exports.default = _default;