Skip to content

add support for aliases in the npm cli detector#1680

Open
dterrybd wants to merge 2 commits intodev/dterry/IDETECT-4965-npm-alias-featurefrom
dev/dterry/IDETECT-4965-npm-cli-alias
Open

add support for aliases in the npm cli detector#1680
dterrybd wants to merge 2 commits intodev/dterry/IDETECT-4965-npm-alias-featurefrom
dev/dterry/IDETECT-4965-npm-cli-alias

Conversation

@dterrybd
Copy link
Contributor

This PR builds upon the previous npm package json detector changes.

It extracts existing code to a new NpmAliasParser that can be used by both the CLI and the package JSON detectors.

It then alters the NpmCliParser to build a map of alias names to actual package names. This is called once at the start of parsing for efficiency.

When dependencies are about to be made and added to the graph, this aliasMapping structure is used to get the true package name. From here the previous code paths are leveraged.

* @return true if the value is an npm alias (starts with "npm:")
*/
public static boolean isNpmAlias(String value) {
return value != null && value.startsWith("npm:");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we could use static final constants here as npm: prefix is used in multiple places. Also for other constant symbols (e.g., @, / etc.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants