0
0
Fork 0
mirror of https://github.com/renovatebot/renovate.git synced 2025-05-12 23:51:55 +00:00
renovatebot_renovate/lib/modules/manager/bun/utils.ts
Maximilian Dewald 56d82cae5a
feat(bun): workspaces (#35010)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2025-04-17 14:25:53 +00:00

27 lines
705 B
TypeScript

import upath from 'upath';
import { minimatch } from '../../../util/minimatch.js';
export function fileMatchesWorkspaces(
pwd: string,
fileName: string,
workspaces: string[],
): boolean {
if (!fileName.startsWith(pwd)) {
return false;
}
const relativeFile = upath
.relative(pwd, fileName)
.replace(/\/package\.json$/, '');
return workspaces.some((pattern) =>
// minimatch will also return true for an exact match
minimatch(pattern, { dot: true }).match(relativeFile),
);
}
export function filesMatchingWorkspaces(
pwd: string,
files: string[],
workspaces: string[],
): string[] {
return files.filter((file) => fileMatchesWorkspaces(pwd, file, workspaces));
}