【问题标题】:Specifying latest revision of a particular branch with bower使用 bower 指定特定分支的最新版本
【发布时间】:2013-04-02 21:22:33
【问题描述】:

我想将特定分支的最新版本指定为依赖项。具体来说,我想在 Bootstrap v3.0 发布之前使用它。

在 bower 中将其指定为依赖项的最佳方法是什么?

【问题讨论】:

标签: bower


【解决方案1】:

您需要使用#appended to the component name

bower install bootstrap#version3-branch-name

如您所料,如果您将--save-dev 添加到其中,那么它将添加到您的bower.json 文件中:

"bootstrap": "version3-branch-name"

【讨论】:

  • 这行得通,应该被赞成。另一个例子"ckeditor": "#basic/latest" 代表github.com/ckeditor/ckeditor-releases
  • 这是否会在重新运行 bower install 时自动从同一分支中提取新更改?
  • 不,这就是为什么建议使用提交 SHA。
【解决方案2】:

您可以指定提交 SHA 而不是版本:

bower install bootstrap#37d0a30589

请注意,在生产或可重用模块中指定分支是不好的做法,因为它是一个移动目标,最终会破坏某些东西。讨论一下here

【讨论】:

  • 这是什么状态?
  • 我们可以使用<library>#<branch_name>吗?
【解决方案3】:

直到 bower 能够 target a specific commit @Sindre 指出的那样,我正在利用 bower 定位任意 zip 文件的能力。我在我的 component.json 中指定了 github 的 bootstrap 3.0 分支的 zip:

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

我知道这是针对分支(而不是特定提交)的不好做法,但这对我来说现在是权宜之计。

【讨论】:

  • 我不确定这本身是否是一种不好的做法,这取决于您如何使用它。
  • Bower 现在允许您定位特定的提交
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-08-21
  • 2013-10-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-11-07
  • 2020-06-24
相关资源
最近更新 更多