(fromDir: string, moduleId: string, cacheKey: string)
| 80 | } |
| 81 | |
| 82 | resolveModuleManually(fromDir: string, moduleId: string, cacheKey: string) { |
| 83 | const root = normalizePath(path.parse(fromDir).root); |
| 84 | |
| 85 | let dir = normalizePath(path.join(fromDir, 'noop.js')); |
| 86 | let packageJsonFilePath: string; |
| 87 | |
| 88 | while (dir !== root) { |
| 89 | dir = normalizePath(path.dirname(dir)); |
| 90 | packageJsonFilePath = path.join(dir, 'node_modules', moduleId, 'package.json'); |
| 91 | |
| 92 | if (!fs.existsSync(packageJsonFilePath)) { |
| 93 | continue; |
| 94 | } |
| 95 | |
| 96 | this.resolveModuleCache.set(cacheKey, packageJsonFilePath); |
| 97 | |
| 98 | return packageJsonFilePath; |
| 99 | } |
| 100 | |
| 101 | throw new Error(`error loading "${moduleId}" from "${fromDir}"`); |
| 102 | } |
| 103 | } |
no test coverage detected