Handle npm package aliases.
npm supports aliasing packages with the npm: prefix syntax:
"my-react": "npm:react@^18.0.0"This allows installing a package under a different name, useful for running multiple versions of the same package side by side.
Summary
Functions
Check if a dependency specifier is an alias.
Parse an alias specifier.
Extract the real package name from an alias specifier.
Functions
Check if a dependency specifier is an alias.
Parse an alias specifier.
Returns {:alias, package, range} if the specifier uses npm: prefix,
or {:normal, range} otherwise.
Examples
iex> NPM.Alias.parse("npm:react@^18.0.0")
{:alias, "react", "^18.0.0"}
iex> NPM.Alias.parse("npm:@scope/pkg@1.0.0")
{:alias, "@scope/pkg", "1.0.0"}
iex> NPM.Alias.parse("^1.0.0")
{:normal, "^1.0.0"}
Extract the real package name from an alias specifier.
Returns the original name if not an alias.