Skip to content

Commit c9ee866

Browse files
committed
fix(clone): version order error
The latest tag from simple-git isn't the current latest. So let's replace that with tags sorted by semver.
1 parent 536fece commit c9ee866

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/cloneRepository.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const { join } = require('path')
44
const paths = require('./paths')
55
const { promisify } = require('util')
66
const throwError = require('./throwError')
7+
const semver = require('semver')
78

89

910
const access = promisify(fs.access)
@@ -21,7 +22,11 @@ module.exports = async (repository, version) => {
2122
}
2223

2324
const gitT = git(templatePath)
24-
const tags = await gitT.tags()
25+
let tags = await gitT.tags()
26+
tags = tags.all
27+
.filter(semver.valid)
28+
.sort(semver.compare)
29+
.reverse()
2530

2631
const branchSummary = await gitT.branch()
2732
const currentBranch = branchSummary.current
@@ -38,8 +43,9 @@ module.exports = async (repository, version) => {
3843
}
3944

4045
gitT.checkout(version)
41-
} else if (tags.latest) {
42-
await gitT.checkout(tags.latest)
46+
} else if (tags.length) {
47+
console.log(tags)
48+
await gitT.checkout(tags[0])
4349
}
4450

4551
return { templatePath, currentBranch }

0 commit comments

Comments
 (0)