Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak the 'vV' replacing logic and mimic Bower and NPM behavior #123

Merged
merged 2 commits into from
Jun 4, 2015
Merged

Tweak the 'vV' replacing logic and mimic Bower and NPM behavior #123

merged 2 commits into from
Jun 4, 2015

Conversation

alexandernst
Copy link
Contributor

Those 2 commits greatly improve this plugin. I'm pasting here the commit messages as they describe pretty well what each commit does:

commit 1

Currently the 'vV' chars are replaced with str_replace,
after a preg_match. Because of how str_replace works, this could
lead to some potential bugs. Replace with a single preg_replace
that will handle the job in exactly the same way.

As a side bonus, we're getting rid of a loop, which could speed
up things a little bit.

commit 2

Mimic the behavior of NPM and Bower when comparing versions
constructed by 1 or 2 groups of numbers.

Versions as "1", "7.9", "v4" and "v98.2" are perfectly valid
and both Bower and NPM expand those to, accordingly, "1.",
"7.9.
", "v4." and "v98.2.". Until now this plugin
failed at doing so, which causes quite some failures when
trying to install packages that use that syntax (npmconf,
just to name one).

This commit fixes that by adding a single regex replace
that matches 1 or 2 groups of numbers and appends an ".*".
Also, the regex keeps in mind that other type of versions,
such as "~2" or ">=4.5" don't need to be expanded.

Also note that this fix will not break current unit
tests.

Currently the 'vV' chars are replaced after with str_replace,
after a preg_match. Because of how str_replace works, this could
lead to some potential bugs. Replace with a single preg_replace
that will handle the job in exactly the same way.

As a side bonus, we're getting rid of a loop, which could speed
up things a little bit.
constructed by 1 or 2 groups of numbers.

Versions as "1", "7.9", "v4" and "v98.2" are perfectly valid
and both Bower and NPM expand those to, accordingly, "1.*",
"7.9.*", "v4.*" and "v98.2.*". Until now this plugin
failed at doing so, which causes quite some failures when
trying to install packages that use that syntax (npmconf,
just to name one).

This commit fixes that by adding a single regex replace
that matches groups of numbers and appends a ".*". Also,
the regex keeps in mind that other type of versions,
such as "~2" or ">=4.5" don't need to be expanded.

Also note that this fix will not break current unit
tests.
@alexandernst alexandernst changed the title Tweak the 'vV' replacing logic. Tweak the 'vV' replacing logic and mimic Bower and NPM behavior Jun 3, 2015
@francoispluchino francoispluchino merged commit e982d0d into fxpio:master Jun 4, 2015
@alexandernst
Copy link
Contributor Author

@francoispluchino Thank you for merging this!
Do you plan releasing a patch version (maybe 1.0.1.1?) including this fix? The issues described in #122 prevent this plugin from working correctly with a lot of packages and imho having a stable version of this plugin with this PR will benefit everybody.

@francoispluchino
Copy link
Member

@alexandernst The new version 1.0.2 is available.

@alexandernst
Copy link
Contributor Author

Oh, nice! Thanks!

@francoispluchino francoispluchino added this to the 1.0.2 milestone Jul 1, 2016
@francoispluchino francoispluchino modified the milestones: 1.0.2, 1.0 May 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants