diff --git a/src/mergeAxeResults.ts b/src/mergeAxeResults.ts index 37f0b9c5..9ce3c052 100644 --- a/src/mergeAxeResults.ts +++ b/src/mergeAxeResults.ts @@ -28,7 +28,6 @@ import { getBrowserToRun, getPlaywrightLaunchOptions } from './constants/common. import { getWcagPassPercentage, getProgressPercentage, - retryFunction, zipResults, getIssuesPercentage, getWcagCriteriaMap, @@ -40,6 +39,7 @@ import { getStoragePath, getUserDataTxt, getVersion, + retryFunction, } from './utils/index.js'; import { consoleLogger, silentLogger } from './logs.js'; import itemTypeDescription from './constants/itemTypeDescription.js'; diff --git a/src/utils.ts b/src/utils.ts index 83ffe40c..2aa6ed94 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -863,21 +863,6 @@ export const zipResults = async (zipName: string, resultsPath: string): Promise< }); }; -export const retryFunction = async (func: () => Promise, maxAttempt: number): Promise => { - let attemptCount = 0; - while (attemptCount < maxAttempt) { - attemptCount += 1; - try { - // eslint-disable-next-line no-await-in-loop - const result = await func(); - return result; - } catch (error) { - // do nothing, just retry - } - } - throw new Error('Maximum number of attempts reached'); -}; - /** * Determines which WCAG criteria might appear in the "needsReview" category * based on axe-core's rule configuration. diff --git a/src/utils/index.ts b/src/utils/index.ts index 89fe9d3d..9158bcc5 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -4,6 +4,7 @@ export { default as getCurrentDate } from './getCurrentDate.js'; export { default as getStoragePath } from './getStoragePath.js'; export { default as getPdfStoragePath } from './getPdfStoragePath.js'; export { default as isWhitelistedContentType } from './isWhitelistedContentType.js'; +export { default as retryFunction } from './retryFunction.js'; export { default as randomThreeDigitNumberString } from './randomThreeDigitNumberString.js'; export { areLinksEqual, isFollowStrategy } from './linkStrategy.js'; export { getUserDataFilePath, getUserDataTxt, writeToUserDataTxt } from './userData.js'; diff --git a/src/utils/retryFunction.ts b/src/utils/retryFunction.ts new file mode 100644 index 00000000..3e720a02 --- /dev/null +++ b/src/utils/retryFunction.ts @@ -0,0 +1,16 @@ +const retryFunction = async (func: () => Promise, maxAttempt: number): Promise => { + let attemptCount = 0; + while (attemptCount < maxAttempt) { + attemptCount += 1; + try { + // eslint-disable-next-line no-await-in-loop + const result = await func(); + return result; + } catch (error) { + // do nothing, just retry + } + } + throw new Error('Maximum number of attempts reached'); +}; + +export default retryFunction;