2016-02-05 245 views
2

是否有可能如何获得git依赖关系的更新行为?在package.json中使用git标签(适用于git依赖项)

所以我有git的依赖:

"dependencies": { 
"my-module": "github:me/my-module" 
} 

,并希望它在每次我做npm install及时更新,添加修改散列解决方案,但需要更多的工作,以跟踪和updatei中的package.json每次包更新在github上。

也有Git标签(也可使用npm version..命令设置 - 它创造了标签提交v1.2.3所以我想,也许是thiere方式家属的package.json使用这个标签

希望我?清晰。

上repoe

git的标签给我

V1.0.1 V1.0.0 ..

如果我尝试MOD后的package.json添加ULE名版本,如:#1.0.0或#1.0.1

``` 
"dependencies": { 
"my-module": "github:me/my-module#1.0.1" 
} 
``` 

安装失败,错误:

Command failed: git -c core.longpaths=true rev-list -n1 1.0.0 
fatal: ambiguous argument '1.0.0': unknown revision or path not in the 
ree. 
Use '--' to separate paths from revisions, like this: 
'git <command> [<revision>...] -- [<file>...]' 


If you need help, you may report this error at: 
    <https://github.com/npm/npm/issues> 

...

+0

如果'git标签'给你像'v1.0.0'等值,那么你需要使用该确切的值。使用'1.0.0' **将会失败**。 –

回答

3

这可以这样

完成"my-module": "git+https://github.com/user/repo.git#v1.2.3"

+0

似乎不起作用,添加在OP – WHITECOLOR

+0

这是行不通的,你有没有把你的标签推到github? 'git push --follow-tags'你的标签名是否正确? –

+0

谢谢,但是有没有像'#^ v1.0.0'这样的东西具有可用性,并且具有修补程序/次要版本的自动更新? – WHITECOLOR

1

如果你正在寻找支持git依赖的semver,恐怕你是o没有运气。

当安装git的依赖,NPM允许您指定下列操作之一,以控制什么特别承诺你哗哗安装的依赖:

  • 提交(的犯满SHA1字符串)
  • 承诺(短提交字符串)
  • 分支
  • 标签

的格式被定义如下:

的package.json:

{ 
    "dependencies": { 
    "some-dep": "username/reponame#commit-ish" 
    } 
} 

哪里commit-ish是上面列出的项目之一。

试图在指定commit-ish时使用其中一个semver修饰符将失败,即。 #~1.2.3不是有效的commit-ishSee the docs for yourself

+0

似乎不工作,在OP中添加 – WHITECOLOR

0

我试过使用git + ssh,但没有工作。最后,这对我在bitbucket中的回购有效

"my-module": "git+https://bitbucket.org/repos/myrepo/#0.1.0"