in src/debugAdapter/contracts/contractJsonsProvider.ts [31:61]
public async getJsonsContents(): Promise<{ [fileName: string]: IContractJsonModel }> {
if (!this._cachedContractJsons) {
const isDirectoryExist = await this.isDirectoryExist();
if (!isDirectoryExist) {
this._cachedContractJsons = {};
} else {
const dir = this.contractBuildDirectory;
const response = new Promise<{ [fileName: string]: IContractJsonModel }>((accept) => {
fs.readdir(dir, async (error: any, files: any[]) => {
if (error) {
throw new Error(`Error occured while reading directory ${dir}`);
}
const result: { [fileName: string]: IContractJsonModel } = {};
for (const file of files) {
const fullPath = path.join(dir, file);
const content = await this.readFile(fullPath, this.contractJsonEncoding);
try {
result[file] = JSON.parse(content) as IContractJsonModel;
} catch (e) {
throw new Error(`Error while parsing ${fullPath}. Invalid json file.`);
}
}
accept(result);
});
});
this._cachedContractJsons = await response;
}
}
return this._cachedContractJsons;
}