forked from renovatebot/renovate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.ts
41 lines (36 loc) · 1.19 KB
/
common.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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.undefined((include as GitlabIncludeComponent).component);
}