()
| 106 | } |
| 107 | |
| 108 | private load() { |
| 109 | const json = fs.readFileSync(this.packageConfigPath, "utf8"); |
| 110 | try { |
| 111 | this.config = JSON.parse(json); |
| 112 | } catch (e) { |
| 113 | this.logger.warn(`Failed to load package map at ${this.packageConfigPath}, continuing with empty map: ${e}`); |
| 114 | this.map = {}; |
| 115 | return; |
| 116 | } |
| 117 | |
| 118 | this.map = {}; |
| 119 | for (const pkg of this.config.packages) { |
| 120 | const packageConfigFolderPath = path.dirname(this.packageConfigPath); |
| 121 | const packageRootPath = this.getPathForUri(pkg.rootUri); |
| 122 | if (packageRootPath) { |
| 123 | const packageLibPath = this.getPathForUri(pkg.packageUri); |
| 124 | this.map[pkg.name] = path.resolve(packageConfigFolderPath, packageRootPath, packageLibPath ?? ""); |
| 125 | } else { |
| 126 | this.logger.error(`Failed to resolve path for package ${pkg.name}, did not resolve a valid rootUri`); |
| 127 | } |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | private getPathForUri(uri: string): string | undefined { |
| 132 | if (!uri) |
no test coverage detected