Skip to content

Commit

Permalink
fix(contributor): delete mock import
Browse files Browse the repository at this point in the history
  • Loading branch information
samuel-gomez-axa committed Mar 21, 2023
1 parent 80534fa commit 303e1d4
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions gulpfile.babel.js/generateContributors.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint-disable arrow-parens */
import path, { resolve } from 'path';
import path from 'path';
import fs from 'fs';
import config from './config';
import contrib from './contrib.json';

const { pathSrc } = config;

Expand All @@ -17,23 +16,26 @@ const getContributors = async () => {
);
const responseJson = await response.json();
return responseJson;
};
};


const generateContributors = async () => {
const contributorsRaw = await getContributors();
const reservedContributors = contributorsRaw.reverse();
const contributors = reservedContributors.map(({ weeks, total, ...restContributor }) => {
const additions = weeks.map(({ a }) => a).reduce((acc, curr) => acc + curr);
const deletions = weeks.map(({ d }) => d).reduce((acc, curr) => acc + curr);
const power = Number(total) + Number(additions) + Number(deletions);
return {
...restContributor,
additions,
deletions,
power,
total,
};
}).sort((a, b) => b.power - a.power);
const reservedContributors = contributorsRaw?.reverse() ?? [];
const contributors = reservedContributors
.map(({ weeks, total, ...restContributor }) => {
const additions = weeks.map(({ a }) => a).reduce((acc, curr) => acc + curr);
const deletions = weeks.map(({ d }) => d).reduce((acc, curr) => acc + curr);
const power = Number(total) + Number(additions) + Number(deletions);
return {
...restContributor,
additions,
deletions,
power,
total,
};
})
.sort((a, b) => b.power - a.power);

let contentFile = '.tk-contributors\n';

Expand All @@ -49,7 +51,6 @@ const generateContributors = async () => {
contentFile += ` span.tk-contributor__additions Additions : ${additions} ++\n`;
contentFile += ` span.tk-contributor__deletions Deletions : ${deletions} --\n`;
contentFile += ` span.tk-contributor power : ${power}\n`;

});

if (!fs.existsSync(pathContributorsPugTemplate)) {
Expand Down

0 comments on commit 303e1d4

Please sign in to comment.