From 9d8629b1ba1e2ee3dcb0efed11493de25006e5ac Mon Sep 17 00:00:00 2001 From: Amio Date: Fri, 10 Aug 2018 12:57:20 +0800 Subject: [PATCH] live-fns: report unknown topic on coveralls badge --- libs/live-fns/coveralls.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/libs/live-fns/coveralls.js b/libs/live-fns/coveralls.js index 2726413..1823b95 100644 --- a/libs/live-fns/coveralls.js +++ b/libs/live-fns/coveralls.js @@ -2,17 +2,22 @@ const axios = require('../axios.js') const covColor = require('../utils/cov-color.js') module.exports = async function (topic, platform, user, repo, branch) { - // only support topic="c" fow now - const query = branch ? `?branch=${branch}` : '' const endpoint = `https://coveralls.io/${platform}/${user}/${repo}.json${query}` /* eslint-disable camelcase */ const { covered_percent } = await axios.get(endpoint).then(res => res.data) - return { - subject: 'coverage', - status: Number(covered_percent.toFixed(1)) + '%', - color: covColor(covered_percent) + switch (topic) { + case 'c': + return { + subject: 'coverage', + status: Number(covered_percent.toFixed(1)) + '%', + color: covColor(covered_percent) + } + default: + return { + status: 'unknown topic' + } } }