From bb941c460be08cd9d1216acf6401dcb67bfca66a Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Tue, 6 Sep 2022 11:15:19 +0100 Subject: [PATCH] fix: wait for new version of old package --- src/npm.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/npm.ts b/src/npm.ts index 7c4ea21..c09cb61 100644 --- a/src/npm.ts +++ b/src/npm.ts @@ -17,9 +17,11 @@ export const validatePackage = async (packageName: string, pluginVersion: string core.info(`Found package ${packageAndVersion} in the npm registry`) return true } catch (error) { - const { statusCode } = error as Error & { statusCode: number } - if (statusCode) { - core.warning(`${packageAndVersion} does no exist in npm registry`) + const { statusCode, code } = error as Error & { statusCode?: number; code?: string } + // If the package is new and not yet published then there will be a 404. + // If the package exists but the version hasn't been published yet then there will be an ETARGET error. + if (statusCode || code === 'ETARGET') { + core.warning(`${packageAndVersion} does not exist in npm registry yet. Checking again shortly...`) return false } throw error