问题
I maintain an AngularJS library called Angular Modal Service. I would like to change the dependencies so that I target AngularJS 1.3, like this:
"dependencies": {
"angular": "~1.3.0"
}
However, I know categorically that the library works for ~1.2. I don't want to force consumers who want the latest version of my code to have to upgrade, it is possible to do this:
"dependencies": {
"angular": "~1.3.0 | ~1.2.0"
}
Letting my library remain low impact? And if it is possible, is it in fact appropriate? Are there any good guidelines on this?
回答1:
One of the things you can do is use your lowest minimum version and allow every version greater than that
>=1.2.0
But what might be better is to also put the highest possible version that you have tested just in case there is a future version that isn't compatible.
>=1.2.0 <=1.3.0
Or a shorthand version of that might look something like this
1.2.0 - 1.3.0
If you remove the second equal sign from the above what you end up with is a version syntax that node calls an x-range which can be shortened to this
1.2.x
which is the same as
>=1.2.0 <1.3.0
All of this and more can be found on the node semver page.
来源:https://stackoverflow.com/questions/27108084/supporting-multiple-versions-of-angularjs