Skip to content

Commit 9ff3c17

Browse files
guox191yyx990803
authored andcommitted
Compatible with github API error message (vuejs#131)
* Compatible with github API error message * Remove unneccessary log
1 parent 59e51a4 commit 9ff3c17

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

bin/vue-list

+13-8
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,17 @@ request({
2424
}
2525
}, function (err, res, body) {
2626
if (err) logger.fatal(err)
27-
console.log(' Available official templates:')
28-
console.log()
29-
JSON.parse(body).forEach(function (repo) {
30-
console.log(
31-
' ' + chalk.yellow('★') +
32-
' ' + chalk.blue(repo.name) +
33-
' - ' + repo.description)
34-
})
27+
var requestBody = JSON.parse(body)
28+
if (Array.isArray(requestBody)) {
29+
console.log(' Available official templates:')
30+
console.log()
31+
requestBody.forEach(function (repo) {
32+
console.log(
33+
' ' + chalk.yellow('★') +
34+
' ' + chalk.blue(repo.name) +
35+
' - ' + repo.description)
36+
})
37+
} else {
38+
console.error(requestBody.message)
39+
}
3540
})

0 commit comments

Comments
 (0)