/// <summary> /// Finds the child directory of the given name within any of the parent directories (e.g. like node_modules /// resolution) /// </summary> /// <param name="path"></param> /// <param name="directoryName"></param> /// <returns></returns> public static IEnumerable <FPath> SubDirectoriesOfParent(this FPath path, string directoryName) => path.EnumerateParents().Select(p => p.Directories(directoryName)).Where(p => !p.IsEmtpy());
/// <summary> /// Finds the first parent that satisfies the predicate /// </summary> public static FPath Parent(this FPath path, Predicate <FPath> predicate) => path.EnumerateParents().FirstOrDefault(p => predicate(p));
public static FPath DirOfParent(this FPath path, string searchPattern) => path.EnumerateParents().Select(p => p.Directories(searchPattern, false)).FirstOrDefault(d => !d.IsEmtpy());
public static FPath ParentWithFile(this FPath path, string filePattern) => path.EnumerateParents().FirstOrDefault(p => p.Files(filePattern, false).HasValue());
public static FPath FileOfParent(this FPath path, string searchPattern) => path.EnumerateParents().Select(p => p.Files(searchPattern, false)).FirstOrDefault(f => !f.IsEmtpy());