From 92f4de3970057381062638bd8d0c2bfb6f025f86 Mon Sep 17 00:00:00 2001 From: platane Date: Tue, 17 Oct 2023 17:30:48 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20use=20process.env.=20instead=20of?= =?UTF-8?q?=20@action/core=20in=20test=20and=20local?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/action/__tests__/generateContributionSnake.spec.ts | 3 +-- packages/demo/webpack.config.ts | 4 +--- .../api/github-user-contribution/[userName].ts | 3 +-- .../__tests__/getGithubUserContribution.spec.ts | 3 +-- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/action/__tests__/generateContributionSnake.spec.ts b/packages/action/__tests__/generateContributionSnake.spec.ts index 17fb2df45..630afe3df 100644 --- a/packages/action/__tests__/generateContributionSnake.spec.ts +++ b/packages/action/__tests__/generateContributionSnake.spec.ts @@ -1,6 +1,5 @@ import * as fs from "fs"; import * as path from "path"; -import * as core from "@actions/core"; import { generateContributionSnake } from "../generateContributionSnake"; import { parseOutputsOption } from "../outputsOptions"; import { config } from "dotenv"; @@ -34,7 +33,7 @@ it( const outputs = parseOutputsOption(entries); const results = await generateContributionSnake("platane", outputs, { - githubToken: core.getInput("github_token"), + githubToken: process.env.GITHUB_TOKEN!, }); expect(results[0]).toBeDefined(); diff --git a/packages/demo/webpack.config.ts b/packages/demo/webpack.config.ts index fd952e57b..4a20e8e70 100644 --- a/packages/demo/webpack.config.ts +++ b/packages/demo/webpack.config.ts @@ -1,7 +1,6 @@ import path from "path"; import HtmlWebpackPlugin from "html-webpack-plugin"; import webpack from "webpack"; -import * as core from "@actions/core"; import { getGithubUserContribution } from "@snk/github-user-contribution"; import { config } from "dotenv"; import type { Configuration as WebpackConfiguration } from "webpack"; @@ -17,8 +16,7 @@ const webpackDevServerConfiguration: WebpackDevServerConfiguration = { const userName: string = req.params.userName; res.send( await getGithubUserContribution(userName, { - githubToken: - process.env.GITHUB_TOKEN ?? core.getInput("github_token"), + githubToken: process.env.GITHUB_TOKEN!, }) ); }); diff --git a/packages/github-user-contribution-service/api/github-user-contribution/[userName].ts b/packages/github-user-contribution-service/api/github-user-contribution/[userName].ts index f2decd56b..59cd76369 100644 --- a/packages/github-user-contribution-service/api/github-user-contribution/[userName].ts +++ b/packages/github-user-contribution-service/api/github-user-contribution/[userName].ts @@ -1,4 +1,3 @@ -import * as core from "@actions/core"; import { getGithubUserContribution } from "@snk/github-user-contribution"; import { VercelRequest, VercelResponse } from "@vercel/node"; import nodeFetch from "node-fetch"; @@ -13,7 +12,7 @@ export default async (req: VercelRequest, res: VercelResponse) => { res.statusCode = 200; res.json( await getGithubUserContribution(userName as string, { - githubToken: process.env.GITHUB_TOKEN ?? core.getInput("github_token"), + githubToken: process.env.GITHUB_TOKEN!, }) ); } catch (err) { diff --git a/packages/github-user-contribution/__tests__/getGithubUserContribution.spec.ts b/packages/github-user-contribution/__tests__/getGithubUserContribution.spec.ts index 97014cbd2..d9964debc 100644 --- a/packages/github-user-contribution/__tests__/getGithubUserContribution.spec.ts +++ b/packages/github-user-contribution/__tests__/getGithubUserContribution.spec.ts @@ -1,11 +1,10 @@ -import * as core from "@actions/core"; import { getGithubUserContribution } from ".."; import { config } from "dotenv"; config({ path: __dirname + "/../../../.env" }); describe("getGithubUserContribution", () => { const promise = getGithubUserContribution("platane", { - githubToken: process.env.GITHUB_TOKEN ?? core.getInput("github_token"), + githubToken: process.env.GITHUB_TOKEN!, }); it("should resolve", async () => {