From 811aef84cb139f8e0a7a5886e73b2da1aee21c99 Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Mon, 1 Sep 2025 15:14:57 +0100 Subject: [PATCH] Move `isDefined` from `start-proxy` to `util` --- lib/start-proxy-action.js | 6 +++--- src/start-proxy.ts | 11 +---------- src/util.ts | 9 +++++++++ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/start-proxy-action.js b/lib/start-proxy-action.js index 5881cacea..9670648c8 100644 --- a/lib/start-proxy-action.js +++ b/lib/start-proxy-action.js @@ -47753,6 +47753,9 @@ async function delay(milliseconds, opts) { function getErrorMessage(error2) { return error2 instanceof Error ? error2.message : String(error2); } +function isDefined(value) { + return value !== void 0 && value !== null; +} // src/actions-util.ts var pkg = require_package(); @@ -47825,9 +47828,6 @@ var LANGUAGE_TO_REGISTRY_TYPE = { rust: "cargo_registry", go: "goproxy_server" }; -function isDefined(value) { - return value !== void 0 && value !== null; -} function getCredentials(logger, registrySecrets, registriesCredentials, languageString) { const language = languageString ? parseLanguage(languageString) : void 0; const registryTypeForLanguage = language ? LANGUAGE_TO_REGISTRY_TYPE[language] : void 0; diff --git a/src/start-proxy.ts b/src/start-proxy.ts index d74884bfd..08da18291 100644 --- a/src/start-proxy.ts +++ b/src/start-proxy.ts @@ -2,7 +2,7 @@ import * as core from "@actions/core"; import { KnownLanguage } from "./languages"; import { Logger } from "./logging"; -import { ConfigurationError } from "./util"; +import { ConfigurationError, isDefined } from "./util"; export type Credential = { type: string; @@ -65,15 +65,6 @@ const LANGUAGE_TO_REGISTRY_TYPE: Partial> = { go: "goproxy_server", } as const; -/** - * Checks that `value` is neither `undefined` nor `null`. - * @param value The value to test. - * @returns Narrows the type of `value` to exclude `undefined` and `null`. - */ -function isDefined(value: T | null | undefined): value is T { - return value !== undefined && value !== null; -} - // getCredentials returns registry credentials from action inputs. // It prefers `registries_credentials` over `registry_secrets`. // If neither is set, it returns an empty array. diff --git a/src/util.ts b/src/util.ts index 1ac24ad12..5ef037636 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1278,3 +1278,12 @@ export async function asyncSome( const results = await Promise.all(array.map(predicate)); return results.some((result) => result); } + +/** + * Checks that `value` is neither `undefined` nor `null`. + * @param value The value to test. + * @returns Narrows the type of `value` to exclude `undefined` and `null`. + */ +export function isDefined(value: T | null | undefined): value is T { + return value !== undefined && value !== null; +}