Skip to content

Commit

Permalink
Add 4 different style options
Browse files Browse the repository at this point in the history
  • Loading branch information
datejer committed Nov 26, 2020
1 parent fc04e75 commit ca277a7
Show file tree
Hide file tree
Showing 21 changed files with 39 additions and 6 deletions.
30 changes: 24 additions & 6 deletions api/[owner]/[repo].js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ const fs = require("fs");
module.exports = (req, res) => {
const { owner, repo } = req.query;

let style;
if (!req.query.style) style = "flat";
else if (
req.query.style === "flat" ||
req.query.style === "flat-square" ||
req.query.style === "for-the-badge" ||
req.query.style === "plastic"
)
style = req.query.style;

axios
.get(`https://api.github.com/repos/${owner}/${repo}/deployments`, {
headers: {
Expand All @@ -17,7 +27,9 @@ module.exports = (req, res) => {
if (response.data.length <= 0) {
res.setHeader("Content-Type", "image/svg+xml");
return fs
.createReadStream(path.join(__dirname, "../../assets/none.svg"))
.createReadStream(
path.join(__dirname, `../../assets/${style}/none.svg`)
)
.pipe(res);
}

Expand All @@ -31,7 +43,9 @@ module.exports = (req, res) => {
if (vercelDeployments.length <= 0) {
res.setHeader("Content-Type", "image/svg+xml");
return fs
.createReadStream(path.join(__dirname, "../../assets/none.svg"))
.createReadStream(
path.join(__dirname, `../../assets/${style}/none.svg`)
)
.pipe(res);
}

Expand All @@ -50,25 +64,29 @@ module.exports = (req, res) => {
if (response.data[0].state === "success")
return fs
.createReadStream(
path.join(__dirname, "../../assets/passing.svg")
path.join(__dirname, `../../assets/${style}/passing.svg`)
)
.pipe(res);
else if (response.data[0].state === "failure")
return fs
.createReadStream(path.join(__dirname, "../../assets/failed.svg"))
.createReadStream(
path.join(__dirname, `../../assets/${style}/failed.svg`)
)
.pipe(res);
else if (response.data[0].state === "pending")
return fs
.createReadStream(
path.join(__dirname, "../../assets/pending.svg")
path.join(__dirname, `../../assets/${style}/pending.svg`)
)
.pipe(res);
});
})
.catch((error) => {
res.setHeader("Content-Type", "image/svg+xml");
return fs
.createReadStream(path.join(__dirname, "../../assets/error.svg"))
.createReadStream(
path.join(__dirname, `../../assets/${style}/error.svg`)
)
.pipe(res);
});
};
1 change: 1 addition & 0 deletions assets/flat-square/error.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/flat-square/failed.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/flat-square/none.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/flat-square/passing.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/flat-square/pending.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
1 change: 1 addition & 0 deletions assets/for-the-badge/error.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/for-the-badge/failed.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/for-the-badge/none.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/for-the-badge/passing.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/for-the-badge/pending.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/plastic/error.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/plastic/failed.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/plastic/none.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/plastic/passing.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/plastic/pending.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

1 comment on commit ca277a7

@vercel
Copy link

@vercel vercel bot commented on ca277a7 Nov 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.