Skip to content

Commit

Permalink
Converted github api helpers to ModuleJS
Browse files Browse the repository at this point in the history
  • Loading branch information
BradyMitch committed Jun 26, 2024
1 parent 6d767b8 commit 0e69bad
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { createIssue, closeIssue, findIssueByTitle } = require('./github-api-requests.cjs');
import { createIssue, closeIssue, findIssueByTitle } from './github-api-requests.cjs';

/**
* FILE DOES NOT NEED TO BE EDITED.
Expand All @@ -18,4 +18,4 @@ const createAndCloseExistingIssue = async (issueTitle, issueBody) => {
await createIssue(issueTitle, decodeURIComponent(issueBody));
};

module.exports = createAndCloseExistingIssue;
export default createAndCloseExistingIssue;
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
* run: node .github/helpers/script.js
*/

import { Octokit } from '@octokit/rest';
const { GITHUB_TOKEN, GITHUB_REPOSITORY } = process.env;
const [GITHUB_OWNER, GITHUB_REPO] = GITHUB_REPOSITORY.split("/");
const { Octokit } = require("@octokit/rest");
const [GITHUB_OWNER, GITHUB_REPO] = GITHUB_REPOSITORY.split('/');

// Create a personal access token at https://github.com/settings/tokens/new?scopes=repo
const octokit = new Octokit({ auth: GITHUB_TOKEN });
Expand Down Expand Up @@ -77,7 +77,7 @@ async function closeIssue(issue_number) {
owner: GITHUB_OWNER,
repo: GITHUB_REPO,
issue_number,
state: "closed",
state: 'closed',
});
console.log(request.data);
return request;
Expand All @@ -91,7 +91,7 @@ async function closeIssue(issue_number) {
* @example
* findIssueByTitle('My Issue');
*/
async function findIssueByTitle(title, state = "open") {
async function findIssueByTitle(title, state = 'open') {
const { data: issues } = await octokit.rest.issues.listForRepo({
owner: GITHUB_OWNER,
repo: GITHUB_REPO,
Expand All @@ -106,7 +106,7 @@ async function findIssueByTitle(title, state = "open") {
return null; // Return null if no issue found.
}

module.exports = {
export default {
createIssue,
closeIssue,
findIssueByTitle,
Expand Down
2 changes: 1 addition & 1 deletion .github/helpers/npm-audit/create-report-issues.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require('path');
const createAndCloseExistingIssue = require('../github-api/create-and-close-existing-issue.cjs');
const createAndCloseExistingIssue = require('../github-api/create-and-close-existing-issue.mjs');
const outputText = require(path.resolve(__dirname, `../../../outputText.json`));

/**
Expand Down
2 changes: 1 addition & 1 deletion .github/helpers/npm-deps/create-report-issues.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require('path');
const createAndCloseExistingIssue = require('../github-api/create-and-close-existing-issue.cjs');
const createAndCloseExistingIssue = require('../github-api/create-and-close-existing-issue.mjs');
const outputText = require(path.resolve(__dirname, `../../../outputText.json`));

/**
Expand Down

0 comments on commit 0e69bad

Please sign in to comment.