✨ use process.env. instead of @action/core in test and local
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import * as core from "@actions/core";
|
|
||||||
import { generateContributionSnake } from "../generateContributionSnake";
|
import { generateContributionSnake } from "../generateContributionSnake";
|
||||||
import { parseOutputsOption } from "../outputsOptions";
|
import { parseOutputsOption } from "../outputsOptions";
|
||||||
import { config } from "dotenv";
|
import { config } from "dotenv";
|
||||||
@@ -34,7 +33,7 @@ it(
|
|||||||
const outputs = parseOutputsOption(entries);
|
const outputs = parseOutputsOption(entries);
|
||||||
|
|
||||||
const results = await generateContributionSnake("platane", outputs, {
|
const results = await generateContributionSnake("platane", outputs, {
|
||||||
githubToken: core.getInput("github_token"),
|
githubToken: process.env.GITHUB_TOKEN!,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(results[0]).toBeDefined();
|
expect(results[0]).toBeDefined();
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import HtmlWebpackPlugin from "html-webpack-plugin";
|
import HtmlWebpackPlugin from "html-webpack-plugin";
|
||||||
import webpack from "webpack";
|
import webpack from "webpack";
|
||||||
import * as core from "@actions/core";
|
|
||||||
import { getGithubUserContribution } from "@snk/github-user-contribution";
|
import { getGithubUserContribution } from "@snk/github-user-contribution";
|
||||||
import { config } from "dotenv";
|
import { config } from "dotenv";
|
||||||
import type { Configuration as WebpackConfiguration } from "webpack";
|
import type { Configuration as WebpackConfiguration } from "webpack";
|
||||||
@@ -17,8 +16,7 @@ const webpackDevServerConfiguration: WebpackDevServerConfiguration = {
|
|||||||
const userName: string = req.params.userName;
|
const userName: string = req.params.userName;
|
||||||
res.send(
|
res.send(
|
||||||
await getGithubUserContribution(userName, {
|
await getGithubUserContribution(userName, {
|
||||||
githubToken:
|
githubToken: process.env.GITHUB_TOKEN!,
|
||||||
process.env.GITHUB_TOKEN ?? core.getInput("github_token"),
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import * as core from "@actions/core";
|
|
||||||
import { getGithubUserContribution } from "@snk/github-user-contribution";
|
import { getGithubUserContribution } from "@snk/github-user-contribution";
|
||||||
import { VercelRequest, VercelResponse } from "@vercel/node";
|
import { VercelRequest, VercelResponse } from "@vercel/node";
|
||||||
import nodeFetch from "node-fetch";
|
import nodeFetch from "node-fetch";
|
||||||
@@ -13,7 +12,7 @@ export default async (req: VercelRequest, res: VercelResponse) => {
|
|||||||
res.statusCode = 200;
|
res.statusCode = 200;
|
||||||
res.json(
|
res.json(
|
||||||
await getGithubUserContribution(userName as string, {
|
await getGithubUserContribution(userName as string, {
|
||||||
githubToken: process.env.GITHUB_TOKEN ?? core.getInput("github_token"),
|
githubToken: process.env.GITHUB_TOKEN!,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import * as core from "@actions/core";
|
|
||||||
import { getGithubUserContribution } from "..";
|
import { getGithubUserContribution } from "..";
|
||||||
import { config } from "dotenv";
|
import { config } from "dotenv";
|
||||||
config({ path: __dirname + "/../../../.env" });
|
config({ path: __dirname + "/../../../.env" });
|
||||||
|
|
||||||
describe("getGithubUserContribution", () => {
|
describe("getGithubUserContribution", () => {
|
||||||
const promise = getGithubUserContribution("platane", {
|
const promise = getGithubUserContribution("platane", {
|
||||||
githubToken: process.env.GITHUB_TOKEN ?? core.getInput("github_token"),
|
githubToken: process.env.GITHUB_TOKEN!,
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should resolve", async () => {
|
it("should resolve", async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user