import * as path from 'node:path'; /** * Checks if the given childPath is contained within the parentPath. Resolves * the paths before comparing them, so that relative paths are also supported. */ export function isContainedWithin(parentPath: string, childPath: string): boolean { parentPath = path.resolve(parentPath); childPath = path.resolve(childPath); if (parentPath === childPath) { return true; } return childPath.startsWith(parentPath + path.sep); }