0
0
Fork 0
mirror of https://github.com/renovatebot/renovate.git synced 2025-01-11 13:48:55 +00:00
renovatebot_renovate/lib/modules/manager/pre-commit/parsing.ts
2023-11-07 15:50:29 +00:00

34 lines
905 B
TypeScript

import { hasKey } from '../../../util/object';
import type { PreCommitConfig, PreCommitDependency } from './types';
/**
* Type guard to determine whether the file matches pre-commit configuration format
* Example original yaml:
*
* repos
* - repo: https://github.com/user/repo
* rev: v1.0.0
*/
export function matchesPrecommitConfigHeuristic(
data: unknown,
): data is PreCommitConfig {
return !!(data && typeof data === 'object' && hasKey('repos', data));
}
/**
* Type guard to determine whether a given repo definition defines a pre-commit Git hook dependency.
* Example original yaml portion
*
* - repo: https://github.com/user/repo
* rev: v1.0.0
*/
export function matchesPrecommitDependencyHeuristic(
data: unknown,
): data is PreCommitDependency {
return !!(
data &&
typeof data === 'object' &&
hasKey('repo', data) &&
hasKey('rev', data)
);
}