Skip to content

Commit 8b8fbd5

Browse files
committed
Move isDefined from start-proxy to util
1 parent 53c72c5 commit 8b8fbd5

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

lib/start-proxy-action.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/start-proxy.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as core from "@actions/core";
22

33
import { KnownLanguage } from "./languages";
44
import { Logger } from "./logging";
5-
import { ConfigurationError } from "./util";
5+
import { ConfigurationError, isDefined } from "./util";
66

77
export type Credential = {
88
type: string;
@@ -65,15 +65,6 @@ const LANGUAGE_TO_REGISTRY_TYPE: Partial<Record<KnownLanguage, string>> = {
6565
go: "goproxy_server",
6666
} as const;
6767

68-
/**
69-
* Checks that `value` is neither `undefined` nor `null`.
70-
* @param value The value to test.
71-
* @returns Narrows the type of `value` to exclude `undefined` and `null`.
72-
*/
73-
function isDefined<T>(value: T | null | undefined): value is T {
74-
return value !== undefined && value !== null;
75-
}
76-
7768
// getCredentials returns registry credentials from action inputs.
7869
// It prefers `registries_credentials` over `registry_secrets`.
7970
// If neither is set, it returns an empty array.

src/util.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,3 +1278,12 @@ export async function asyncSome<T>(
12781278
const results = await Promise.all(array.map(predicate));
12791279
return results.some((result) => result);
12801280
}
1281+
1282+
/**
1283+
* Checks that `value` is neither `undefined` nor `null`.
1284+
* @param value The value to test.
1285+
* @returns Narrows the type of `value` to exclude `undefined` and `null`.
1286+
*/
1287+
export function isDefined<T>(value: T | null | undefined): value is T {
1288+
return value !== undefined && value !== null;
1289+
}

0 commit comments

Comments
 (0)