Skip to content

Commit 90088cc

Browse files
authored
refactor: Rename manager result type to MaybePromise (#32977)
1 parent 1d36392 commit 90088cc

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

lib/modules/manager/custom/regex/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import is from '@sindresorhus/is';
22
import type { Category } from '../../../../constants';
33
import type {
44
ExtractConfig,
5+
MaybePromise,
56
PackageDependency,
67
PackageFileContent,
7-
Result,
88
} from '../../types';
99
import { handleAny, handleCombination, handleRecursive } from './strategies';
1010
import type { RegexManagerConfig, RegexManagerTemplates } from './types';
@@ -22,7 +22,7 @@ export function extractPackageFile(
2222
content: string,
2323
packageFile: string,
2424
config: ExtractConfig,
25-
): Result<PackageFileContent | null> {
25+
): MaybePromise<PackageFileContent | null> {
2626
let deps: PackageDependency[];
2727
switch (config.matchStringsStrategy) {
2828
default:

lib/modules/manager/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import type {
66
ExtractConfig,
77
GlobalManagerConfig,
88
ManagerApi,
9+
MaybePromise,
910
PackageFile,
1011
PackageFileContent,
1112
RangeConfig,
12-
Result,
1313
} from './types';
1414
export { hashMap } from './fingerprint.generated';
1515

@@ -65,7 +65,7 @@ export function extractPackageFile(
6565
content: string,
6666
fileName: string,
6767
config: ExtractConfig,
68-
): Result<PackageFileContent | null> {
68+
): MaybePromise<PackageFileContent | null> {
6969
const m = managers.get(manager)! ?? customManagers.get(manager)!;
7070
if (!m) {
7171
return null;

lib/modules/manager/setup-cfg/extract.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import { logger } from '../../../logger';
44
import { newlineRegex, regEx } from '../../../util/regex';
55
import { PypiDatasource } from '../../datasource/pypi';
66
import { normalizePythonDepName } from '../../datasource/pypi/common';
7-
import type { PackageDependency, PackageFileContent, Result } from '../types';
7+
import type {
8+
MaybePromise,
9+
PackageDependency,
10+
PackageFileContent,
11+
} from '../types';
812

913
function getSectionName(str: string): string {
1014
const [, sectionName] = regEx(/^\[\s*([^\s]+)\s*]\s*$/).exec(str) ?? [];
@@ -89,7 +93,7 @@ function parseDep(
8993

9094
export function extractPackageFile(
9195
content: string,
92-
): Result<PackageFileContent | null> {
96+
): MaybePromise<PackageFileContent | null> {
9397
logger.trace('setup-cfg.extractPackageFile()');
9498

9599
let sectionName: string | null = null;

lib/modules/manager/types.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type { FileChange } from '../../util/git/types';
1111
import type { MergeConfidence } from '../../util/merge-confidence/types';
1212
import type { CustomExtractConfig } from './custom/types';
1313

14-
export type Result<T> = T | Promise<T>;
14+
export type MaybePromise<T> = T | Promise<T>;
1515

1616
export interface ManagerData<T> {
1717
managerData?: T;
@@ -258,34 +258,34 @@ export interface ManagerApi extends ModuleApi {
258258
currentValue: string,
259259
bumpVersion: ReleaseType,
260260
packageFile: string,
261-
): Result<BumpPackageVersionResult>;
261+
): MaybePromise<BumpPackageVersionResult>;
262262

263-
detectGlobalConfig?(): Result<GlobalManagerConfig>;
263+
detectGlobalConfig?(): MaybePromise<GlobalManagerConfig>;
264264

265265
extractAllPackageFiles?(
266266
config: ExtractConfig,
267267
files: string[],
268-
): Result<PackageFile[] | null>;
268+
): MaybePromise<PackageFile[] | null>;
269269

270270
extractPackageFile?(
271271
content: string,
272272
packageFile?: string,
273273
config?: ExtractConfig,
274-
): Result<PackageFileContent | null>;
274+
): MaybePromise<PackageFileContent | null>;
275275

276276
getRangeStrategy?(config: RangeConfig): RangeStrategy;
277277

278278
updateArtifacts?(
279279
updateArtifact: UpdateArtifact,
280-
): Result<UpdateArtifactsResult[] | null>;
280+
): MaybePromise<UpdateArtifactsResult[] | null>;
281281

282282
updateDependency?(
283283
updateDependencyConfig: UpdateDependencyConfig,
284-
): Result<string | null>;
284+
): MaybePromise<string | null>;
285285

286286
updateLockedDependency?(
287287
config: UpdateLockedConfig,
288-
): Result<UpdateLockedResult>;
288+
): MaybePromise<UpdateLockedResult>;
289289
}
290290

291291
// TODO: name and properties used by npm manager

0 commit comments

Comments
 (0)