Skip to content

Commit dd4ae4a

Browse files
authored
feat: support "github:" dependencies (#851)
1 parent fb6d54a commit dd4ae4a

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

lib/package-managers/gitTags.js

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const { print } = require('../logging')
88

99
/** Gets remote versions sorted. */
1010
const getSortedVersions = async (name, declaration, options) => {
11+
// if present, github: is parsed as the protocol. This is not valid when passed into remote-git-tags.
12+
declaration = declaration.replace(/^github:/, '')
1113
const { auth, protocol, host, path } = parseGithubUrl(declaration)
1214
const url = `${protocol ? protocol.replace('git+', '') : 'https:'}//${auth ? auth + '@' : ''}${host}/${path}`
1315
let tagMap = new Map()

test/index.test.js

+26
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,32 @@ describe('run', function () {
653653
})
654654
})
655655

656+
it('upgrade short github urls', async () => {
657+
const upgrades = await ncu.run({
658+
packageData: JSON.stringify({
659+
dependencies: {
660+
'ncu-test-v2': 'github:raineorshine/ncu-test-v2#1.0.0'
661+
}
662+
})
663+
})
664+
upgrades.should.deep.equal({
665+
'ncu-test-v2': 'github:raineorshine/ncu-test-v2#2.0.0'
666+
})
667+
})
668+
669+
it('upgrade shortest github urls', async () => {
670+
const upgrades = await ncu.run({
671+
packageData: JSON.stringify({
672+
dependencies: {
673+
'ncu-test-v2': 'raineorshine/ncu-test-v2#1.0.0'
674+
}
675+
})
676+
})
677+
upgrades.should.deep.equal({
678+
'ncu-test-v2': 'raineorshine/ncu-test-v2#2.0.0'
679+
})
680+
})
681+
656682
it('upgrade github http urls with semver', async () => {
657683
const upgrades = await ncu.run({
658684
packageData: JSON.stringify({

0 commit comments

Comments
 (0)