Skip to content

Commit

Permalink
chore: migrate package to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
dessant committed Nov 12, 2023
1 parent 5a25b54 commit 53f3f0c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"bugs": {
"url": "https://github.com/dessant/lock-threads/issues"
},
"type": "module",
"main": "src/index.js",
"scripts": {
"build": "ncc build src/index.js -o dist",
Expand Down
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const core = require('@actions/core');
const github = require('@actions/github');
import core from '@actions/core';
import github from '@actions/github';

const schema = require('./schema');
const {getClient} = require('./utils');
import {schema} from './schema.js';
import {getClient} from './utils.js';

async function run() {
try {
Expand Down
4 changes: 2 additions & 2 deletions src/schema.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Joi = require('joi');
import Joi from 'joi';

const extendedJoi = Joi.extend(joi => {
return {
Expand Down Expand Up @@ -177,4 +177,4 @@ const schema = Joi.object({
'log-output': Joi.boolean().default(false)
});

module.exports = schema;
export {schema};
15 changes: 8 additions & 7 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const core = require('@actions/core');
const github = require('@actions/github');
const {retry} = require('@octokit/plugin-retry');
const {throttling} = require('@octokit/plugin-throttling');
import core from '@actions/core';
import github from '@actions/github';
import {retry} from '@octokit/plugin-retry';
import {throttling} from '@octokit/plugin-throttling';

function getClient(token) {
const rateLimitRetries = 3;
const requestRetries = 3;

const rateLimitCallback = function (
retryAfter,
Expand All @@ -16,14 +16,15 @@ function getClient(token) {
`Request quota exhausted for request ${options.method} ${options.url}`
);

if (retryCount < rateLimitRetries) {
if (retryCount < requestRetries) {
core.info(`Retrying after ${retryAfter} seconds`);

return true;
}
};

const options = {
request: {retries: requestRetries},
throttle: {
onSecondaryRateLimit: rateLimitCallback,
onRateLimit: rateLimitCallback
Expand All @@ -33,4 +34,4 @@ function getClient(token) {
return github.getOctokit(token, options, retry, throttling);
}

module.exports = {getClient};
export {getClient};

0 comments on commit 53f3f0c

Please sign in to comment.