0
0
mirror of https://github.com/renovatebot/renovate.git synced 2024-12-22 13:38:32 +00:00
renovatebot_renovate/lib/modules/manager/gitlabci/common.ts
2024-08-16 16:14:12 +00:00

42 lines
1.2 KiB
TypeScript

import is from '@sindresorhus/is';
import type {
GitlabInclude,
GitlabIncludeComponent,
GitlabIncludeLocal,
GitlabIncludeProject,
GitlabPipeline,
} from '../gitlabci/types';
export function isNonEmptyObject(obj: any): boolean {
return is.object(obj) && Object.keys(obj).length !== 0;
}
export function filterIncludeFromGitlabPipeline(
pipeline: GitlabPipeline,
): GitlabPipeline {
const pipeline_without_include: GitlabPipeline = {};
for (const key of Object.keys(pipeline).filter((key) => key !== 'include')) {
const pipeline_key = key as keyof typeof pipeline;
pipeline_without_include[pipeline_key] = pipeline[pipeline_key];
}
return pipeline_without_include;
}
export function isGitlabIncludeProject(
include: GitlabInclude,
): include is GitlabIncludeProject {
return !is.undefined((include as GitlabIncludeProject).project);
}
export function isGitlabIncludeLocal(
include: GitlabInclude,
): include is GitlabIncludeLocal {
return !is.undefined((include as GitlabIncludeLocal).local);
}
export function isGitlabIncludeComponent(
include: GitlabInclude,
): include is GitlabIncludeComponent {
return is.string((include as GitlabIncludeComponent).component);
}