UNPKG

typescript-language-server

Version:

Language Server Protocol (LSP) implementation for TypeScript using tsserver

17 lines 584 B
import { statSync, existsSync } from 'node:fs'; import { resolve } from 'node:path'; export function findPathToModule(dir, moduleNames) { const stat = statSync(dir); if (stat.isDirectory()) { const candidates = moduleNames.map(moduleName => resolve(dir, moduleName)); const modulePath = candidates.find(existsSync); if (modulePath) { return modulePath; } } const parent = resolve(dir, '..'); if (parent !== dir) { return findPathToModule(parent, moduleNames); } } //# sourceMappingURL=modules-resolver.js.map