-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
local.ts
29 lines (28 loc) · 878 Bytes
/
local.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
import { Preset } from './common';
import * as gitlab from './gitlab';
import * as github from './github';
import { RenovateConfig } from '../common';
import {
PLATFORM_TYPE_GITHUB,
PLATFORM_TYPE_GITLAB,
} from '../../constants/platforms';
export async function getPreset(
pkgName: string,
presetName = 'default',
baseConfig: RenovateConfig
): Promise<Preset> {
const { platform, endpoint } = baseConfig;
if (!platform) {
throw new Error(`Missing platform config for local preset.`);
}
switch (platform.toLowerCase()) {
case PLATFORM_TYPE_GITLAB:
return gitlab.getPresetFromEndpoint(pkgName, presetName, endpoint);
case PLATFORM_TYPE_GITHUB:
return github.getPresetFromEndpoint(pkgName, presetName, endpoint);
default:
throw new Error(
`Unsupported platform '${baseConfig.platform}' for local preset.`
);
}
}