mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-15 17:16:25 +00:00
26 lines
727 B
TypeScript
26 lines
727 B
TypeScript
import { logger } from '../../logger';
|
|
import { getDependency } from './get';
|
|
import { Preset } from '../common';
|
|
|
|
export async function getPreset(
|
|
pkgName: string,
|
|
presetName = 'default'
|
|
): Promise<Preset> {
|
|
const dep = await getDependency(pkgName);
|
|
if (!dep) {
|
|
throw new Error('dep not found');
|
|
}
|
|
if (!dep['renovate-config']) {
|
|
throw new Error('preset renovate-config not found');
|
|
}
|
|
const presetConfig = dep['renovate-config'][presetName];
|
|
if (!presetConfig) {
|
|
const presetNames = Object.keys(dep['renovate-config']);
|
|
logger.info(
|
|
{ presetNames, presetName },
|
|
'Preset not found within renovate-config'
|
|
);
|
|
throw new Error('preset not found');
|
|
}
|
|
return presetConfig;
|
|
}
|