0
I have a directory with subdirectories, and the code checks if these subdirectories are valid by consulting the settings.json
of them, if it has (which is mandatory to be valid), but the $.getJSON
does not work by returning the contents of the file, but rather passing it as argument to a function, however I need the function getThemes
return to list of valid subdirectories when all $.getJSON
are ready, code:
getDirectories = (srcpath) => {
return fs.readdirSync(srcpath).filter(function(file)
{
return !['.', '..'].includes(file) && fs.statSync(path.join(srcpath, file)).isDirectory();
});
}
getThemes = () => {
let directories = getDirectories(path.join(process.cwd(), 'themes'));
let out = [];
for (let dir of directories)
$.getJSON(path.join('themes', dir, 'settings.json')).done((json) => {
if (json.version && json.name)
out.push(json)
})
return out
}
What is this variable
a
in your code? That’s right? It shouldn’t bejson
or something like that in thispush
?– Gabriel Katakura
@Gabrielkatakura yes, I forgot to change, the correct was
json
– Vinícius