MCPcopy Create free account
hub / github.com/Dart-Code/Dart-Code / load

Method load

src/shared/pub/package_map.ts:108–129  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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)

Callers 6

constructorMethod · 0.95
reloadMethod · 0.95
launchRequestFunction · 0.80
initDebuggerFunction · 0.80
loadForProjectFunction · 0.80

Calls 3

getPathForUriMethod · 0.95
warnMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected