Skip to content

Commit

Permalink
Merge pull request #216 from shlomiassaf/fix/importClassesFromDirecto…
Browse files Browse the repository at this point in the history
…ries

fix logic for loading classes from modules
  • Loading branch information
pleerock authored Jul 18, 2017
2 parents bdeb297 + 0ffb61c commit 2765a22
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/util/importClassesFromDirectories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ export function importClassesFromDirectories(directories: string[], formats = ["
const loadFileClasses = function (exported: any, allLoaded: Function[]) {
if (exported instanceof Function) {
allLoaded.push(exported);

} else if (exported instanceof Object) {
Object.keys(exported).forEach(key => loadFileClasses(exported[key], allLoaded));

} else if (exported instanceof Array) {
exported.forEach((i: any) => loadFileClasses(i, allLoaded));
} else if (exported instanceof Object || typeof exported === 'object') {
Object.keys(exported).forEach(key => loadFileClasses(exported[key], allLoaded));
}

return allLoaded;
Expand Down

0 comments on commit 2765a22

Please sign in to comment.