Files
github-stats-extended/apps/backend/scripts/helpers.js
T
Marco Pasqualettiandmartin-mfg 8c065b473f feat: setup monorepo using pnpm (#20)
* tests: fix float problems and PAT problem

* extend CONTRIBUTING.md

* extend build documentation, add GH action, fix build on MacOS

* fix build on Vercel

* update .gitignore and CONTRIBUTING.md

* feat: begin work on monorepo

* chore(actions/basic-build): use pnpm

* fix: vercel-deploy

* docs: updates with new folders

* chore: apply PR review comments

---------

Co-authored-by: martin-mfg <2026226+martin-mfg@users.noreply.github.com>
2026-01-19 14:11:58 +01:00

45 lines
894 B
JavaScript

/**
* @file Contains helper functions used in the scripts.
*/
import { getInput } from "@actions/core";
const OWNER = "anuraghazra";
const REPO = "github-readme-stats";
/**
* Retrieve information about the repository that ran the action.
*
* @param {Object} ctx Action context.
* @returns {Object} Repository information.
*/
export const getRepoInfo = (ctx) => {
try {
return {
owner: ctx.repo.owner,
repo: ctx.repo.repo,
};
} catch (error) {
// Resolve eslint no-unused-vars
error;
return {
owner: OWNER,
repo: REPO,
};
}
};
/**
* Retrieve github token and throw error if it is not found.
*
* @returns {string} GitHub token.
*/
export const getGithubToken = () => {
const token = getInput("github_token") || process.env.GITHUB_TOKEN;
if (!token) {
throw Error("Could not find github token");
}
return token;
};