Sha256: 5253a1933bfac8bc5c0988eb1065a163bcc1d8d96b0b367826e985a7f8b5eeb4
Contents?: true
Size: 729 Bytes
Versions: 74
Compression:
Stored size: 729 Bytes
Contents
import path from "path"; import hq from "alias-hq"; function escapeStringRegexp(string) { return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d"); } export default hq.get(({ rootUrl, baseUrl, paths }) => { return (importPath) => { if (!importPath.includes("@")) { return importPath; } const basePath = path.join(rootUrl, baseUrl); for (const [aliasedPath, replacements] of Object.entries(paths)) { const regexp = new RegExp( "(^|.*/)" + escapeStringRegexp(aliasedPath).replace("\\*", "(.*)") ); importPath = importPath.replace( regexp, path.join(basePath, replacements[0]).replace("*", "$2") ); } return importPath; }; });
Version data entries
74 entries across 74 versions & 1 rubygems