in src/arduino/exampleManager.ts [123:171]
private async parseExamplesFromLibrary(rootPath: string, checkCompatibility: boolean, categorizeIncompatible: boolean = false) {
const examples = [];
const inCompatibles = [];
if (!util.directoryExistsSync(rootPath)) {
return [];
}
const libraries = util.readdirSync(rootPath, true);
for (const library of libraries) {
const propertiesFile = path.join(rootPath, library, "library.properties");
if (checkCompatibility && util.fileExistsSync(propertiesFile)) {
const properties = <any>await util.parseProperties(propertiesFile);
const children = this.parseExamples(path.join(rootPath, library, "examples"));
if (children.length) {
// When missing architectures field in library.properties, fall it back to "*".
if (this.isSupported(properties.architectures || "*")) {
examples.push({
name: library,
path: path.join(rootPath, library),
children,
});
} else if (categorizeIncompatible) {
inCompatibles.push({
name: library,
path: path.join(rootPath, library),
children,
});
}
}
} else {
const children = this.parseExamples(path.join(rootPath, library, "examples"));
if (children.length) {
examples.push({
name: library,
path: path.join(rootPath, library),
children,
});
}
}
}
if (categorizeIncompatible && inCompatibles.length) {
examples.push({
name: "INCOMPATIBLE",
path: "INCOMPATIBLE",
children: inCompatibles,
});
}
return examples;
}