Skip to content
This repository has been archived by the owner on Jul 27, 2024. It is now read-only.

Commit

Permalink
fix: fix language name layout (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hephaest authored Jan 8, 2021
1 parent e0dca62 commit 1d5a321
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ async function main() {
await updateGist(stats);
}

function trimRightStr(str, len) {
// Ellipsis takes 3 positions, so the index of substring is 0 to total length - 3.
return str.length > len ? str.substring(0, len - 3) + "..." : str;
}

async function updateGist(stats) {
let gist;
try {
Expand All @@ -31,7 +36,7 @@ async function updateGist(stats) {
const { name, percent, text: time } = data;

const line = [
name.padEnd(11),
trimRightStr(name, 11).padEnd(11),
time.padEnd(14),
generateBarChart(percent, 21),
String(percent.toFixed(1)).padStart(5) + "%"
Expand Down

0 comments on commit 1d5a321

Please sign in to comment.