Skip to content

Commit

Permalink
refactor(): extract include node modules to a sep function
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Jul 9, 2020
1 parent 480963a commit d78bff5
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/graphql-types.loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,9 @@ export class GraphQLTypesLoader {
}

private async getTypesFromPaths(paths: string | string[]): Promise<string[]> {
let includeNodeModules = false;
const includeNodeModules = this.includeNodeModules(paths);

if (util.isArray(paths)) {
includeNodeModules = paths.some((path) => path.includes('node_modules'));
} else {
includeNodeModules = paths.includes('node_modules');
}

paths = util.isArray(paths)
paths = Array.isArray(paths)
? paths.map((path) => normalize(path))
: normalize(paths);

Expand All @@ -52,4 +46,11 @@ export class GraphQLTypesLoader {

return Promise.all(fileContentsPromises);
}

private includeNodeModules(pathOrPaths: string | string[]): boolean {
if (Array.isArray(pathOrPaths)) {
return pathOrPaths.some((path) => path.includes('node_modules'));
}
return pathOrPaths.includes('node_modules');
}
}

0 comments on commit d78bff5

Please sign in to comment.