Skip to content

Commit

Permalink
feat(dependencies): add support for package aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
jakehamilton committed Oct 16, 2020
1 parent 1e41d4e commit c0953f4
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/titan/src/util/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,21 @@ const publish = (pkg) => {
});
};

const ALIAS_PROTOCOL = "npm:";
const patchDependenciesWithLocals = (pkgsMap, dependencies) => {
for (const [name, version] of Object.entries(dependencies)) {
if (pkgsMap.has(name)) {
if (version.startsWith(ALIAS_PROTOCOL)) {
const alias = parseNameWithVersion(
version.slice(ALIAS_PROTOCOL.length)
);

if (pkgsMap.has(alias.name)) {
const local = pkgsMap.get(alias.name);
if (semver.satisfies(local.config.version, alias.version)) {
dependencies[name] = `file:${local.path}`;
}
}
} else if (pkgsMap.has(name)) {
const local = pkgsMap.get(name);
if (semver.satisfies(local.config.version, version)) {
dependencies[name] = `file:${local.path}`;
Expand Down

0 comments on commit c0953f4

Please sign in to comment.