(names: string | string[], from: string)
| 177 | } |
| 178 | |
| 179 | function findUp(names: string | string[], from: string) { |
| 180 | const filenames = Array.isArray(names) ? names : [names]; |
| 181 | |
| 182 | let currentDir = path.resolve(from); |
| 183 | while (true) { |
| 184 | for (const name of filenames) { |
| 185 | const p = path.join(currentDir, name); |
| 186 | if (existsSync(p)) { |
| 187 | return p; |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | const parentDir = path.dirname(currentDir); |
| 192 | if (parentDir === currentDir) { |
| 193 | break; |
| 194 | } |
| 195 | |
| 196 | currentDir = parentDir; |
| 197 | } |
| 198 | |
| 199 | return null; |
| 200 | } |
| 201 | |
| 202 | /** |
| 203 | * return package manager' name by lock file |
no test coverage detected