diff --git a/package.json b/package.json index 026ee8b..1844d1a 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/index.js b/src/index.js index 1858311..bda1cb8 100644 --- a/src/index.js +++ b/src/index.js @@ -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 { diff --git a/src/schema.js b/src/schema.js index db9cd00..95d9f68 100644 --- a/src/schema.js +++ b/src/schema.js @@ -1,4 +1,4 @@ -const Joi = require('joi'); +import Joi from 'joi'; const extendedJoi = Joi.extend(joi => { return { @@ -177,4 +177,4 @@ const schema = Joi.object({ 'log-output': Joi.boolean().default(false) }); -module.exports = schema; +export {schema}; diff --git a/src/utils.js b/src/utils.js index 54ed5bc..cf21b95 100644 --- a/src/utils.js +++ b/src/utils.js @@ -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, @@ -16,7 +16,7 @@ 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; @@ -24,6 +24,7 @@ function getClient(token) { }; const options = { + request: {retries: requestRetries}, throttle: { onSecondaryRateLimit: rateLimitCallback, onRateLimit: rateLimitCallback @@ -33,4 +34,4 @@ function getClient(token) { return github.getOctokit(token, options, retry, throttling); } -module.exports = {getClient}; +export {getClient};