Handle badly formatted launch config files when calculating workspace stats

This commit is contained in:
Rachel Macfarlane
2018-05-25 15:00:03 -07:00
parent beb8133c95
commit fcbf17e468
+15 -10
View File
@@ -38,21 +38,26 @@ export function collectLaunchConfigs(folder: string): Promise<WorkspaceStatItem[
return resolve([]);
}
const json = JSON.parse(contents.toString());
if (json['configurations']) {
for (const each of json['configurations']) {
const type = each['type'];
if (type) {
if (launchConfigs.has(type)) {
launchConfigs.set(type, launchConfigs.get(type) + 1);
}
else {
launchConfigs.set(type, 1);
try {
const json = JSON.parse(contents.toString());
if (json['configurations']) {
for (const each of json['configurations']) {
const type = each['type'];
if (type) {
if (launchConfigs.has(type)) {
launchConfigs.set(type, launchConfigs.get(type) + 1);
}
else {
launchConfigs.set(type, 1);
}
}
}
}
} catch (e) {
console.log(`Unable to parse ${launchConfig}`);
}
return resolve(asSortedItems(launchConfigs));
});
} else {