Fixes #278 filter files by extension

This commit is contained in:
Joseph Earl
2017-04-14 19:19:45 +01:00
parent 2047fda27c
commit 265146e2d1
9 changed files with 141 additions and 7 deletions

View File

@ -155,7 +155,14 @@ export default class API {
listFiles(path) {
return this.request(`${ this.repoURL }/contents/${ path }`, {
params: { ref: this.branch },
});
})
.then(files => {
if (!Array.isArray(files)) {
throw new Error(`Cannot list files, path ${path} is not a directory but a ${files.type}`);
}
return files;
})
.then(files => files.filter(file => file.type === "file"));
}
readUnpublishedBranchFile(contentKey) {