Specifying latest revision of a particular branch with bower

Bower

Bower Problem Overview


I want to specify the latest revision of a particular branch as a dependency. Specifically, I'd like to use Bootstrap v3.0 before it is released.

What is the best way to specify that as a dependency in bower?

Bower Solutions


Solution 1 - Bower

You need to use the #, appended to the component name:

bower install bootstrap#version3-branch-name

And as you might expect, if you add --save-dev to that, then it will add to your bower.json file:

"bootstrap": "version3-branch-name"

Solution 2 - Bower

You can specify the commit SHA instead of a version:

bower install bootstrap#37d0a30589

Note that specifying a branch in production or reusable modules is bad practice as it's a moving target and will eventually break something. Discussion about it here.

Solution 3 - Bower

Until bower gets the ability to target a specific commit as @Sindre noted, I am taking advantage of bower's ability to target arbitrary zip files. I specified github's zip of bootstrap's 3.0 branch in my component.json:

"bootstrap": "https://github.com/twbs/bootstrap/archive/3.0.0-wip.zip"

I understand this is bad practice to target a branch (rather than a specific commit), but this works for me for now as a stopgap.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionChadView Question on Stackoverflow
Solution 1 - Boweruser1429980View Answer on Stackoverflow
Solution 2 - BowerSindre SorhusView Answer on Stackoverflow
Solution 3 - BowerChadView Answer on Stackoverflow