Skip to content

Commit d28a3e4

Browse files
committed
fix: compatible with the case where the repository field is a string
1 parent 2528e96 commit d28a3e4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/extractProgectBaseInfo.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const git = require('simple-git/promise')
33
const { readJson } = require('./utils')
44

55

6+
const gitUrlRegexp = /((git|ssh|http(s)?)|(git@[\w.]+))(:(\/\/)?)([\w.@:/\-~]+)(\.git)(\/)?$/
7+
68
module.exports = async path => {
79
const view = {}
810

@@ -11,9 +13,14 @@ module.exports = async path => {
1113
view.name = config.name,
1214
view.version = config.version
1315
view.description = config.description
14-
view.repository = config.repository
1516
view.keywords = config.keywords
1617
view.author = config.author
18+
19+
if (typeof config.repository === 'string' && gitUrlRegexp.test(config.repository)) {
20+
view.repository = { url: config.repository }
21+
} else if (typeof config.repository === 'object') {
22+
view.repository = config.repository
23+
}
1724
} catch(e) {
1825
// NOTE: don't care
1926
}

0 commit comments

Comments
 (0)