mirror of
https://github.com/github/codeql-action.git
synced 2026-10-30 01:27:22 +00:00
Move isDefined from start-proxy to util
This commit is contained in:
@@ -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<Record<KnownLanguage, string>> = {
|
||||
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<T>(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.
|
||||
|
||||
@@ -1278,3 +1278,12 @@ export async function asyncSome<T>(
|
||||
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<T>(value: T | null | undefined): value is T {
|
||||
return value !== undefined && value !== null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user