2016-02-05 248 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"