| 
1 |  | -import { promises as fs } from 'fs'  | 
 | 1 | +import { promises as fs, existsSync } from 'fs'  | 
2 | 2 | import { basename, dirname, isAbsolute, join, relative, resolve } from 'path'  | 
3 | 3 | 
 
  | 
4 |  | -import { findUp, findUpMultiple } from 'find-up'  | 
 | 4 | +import { any as findUpAny, up as findUp } from 'empathic/find'  | 
 | 5 | +import { up as walkUp } from 'empathic/walk'  | 
5 | 6 | 
 
  | 
6 | 7 | import { DirType, Environment, FileSystem, findUpOptions } from '../file-system.js'  | 
7 | 8 | 
 
  | 
@@ -68,12 +69,25 @@ export class NodeFS extends FileSystem {  | 
68 | 69 |   }  | 
69 | 70 | 
 
  | 
70 | 71 |   /** Node implementation of finding a file or directory by walking up parent directories. */  | 
71 |  | -  findUp(name: string | readonly string[], options: findUpOptions = {}): Promise<string | undefined> {  | 
72 |  | -    return findUp(name, options)  | 
 | 72 | +  findUp(name: string | string[], options: findUpOptions = {}): Promise<string | undefined> {  | 
 | 73 | +    if (typeof name === 'string') {  | 
 | 74 | +      return Promise.resolve(findUp(name, options))  | 
 | 75 | +    }  | 
 | 76 | +    return Promise.resolve(findUpAny(name, options))  | 
73 | 77 |   }  | 
74 | 78 | 
 
  | 
75 | 79 |   /** Node implementation of finding files or directories by walking up parent directories. */  | 
76 | 80 |   findUpMultiple(name: string | readonly string[], options: findUpOptions = {}): Promise<string[]> {  | 
77 |  | -    return findUpMultiple(name, options)  | 
 | 81 | +    const results: string[] = []  | 
 | 82 | +    const normalisedNames = typeof name === 'string' ? [name] : name;  | 
 | 83 | +    for (const dir of walkUp(options.cwd ?? '.', options)) {  | 
 | 84 | +      for (const potentialName of normalisedNames) {  | 
 | 85 | +        const filePath = join(dir, potentialName);  | 
 | 86 | +        if (existsSync(filePath)) {  | 
 | 87 | +          results.push(filePath);  | 
 | 88 | +        }  | 
 | 89 | +      }  | 
 | 90 | +    }  | 
 | 91 | +    return Promise.resolve(results)  | 
78 | 92 |   }  | 
79 | 93 | }  | 
0 commit comments