Skip to content

Commit

Permalink
Introduce exclude file option in the angular router (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgechev committed Jul 28, 2019
1 parent d9cb0a9 commit 902b6d4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/guess-parser/src/angular/index.ts
Expand Up @@ -395,7 +395,7 @@ const getLazyEntryPoints = (
return module;
};

export const parseRoutes = (tsconfig: string): RoutingModule[] => {
export const parseRoutes = (tsconfig: string, exclude: string[] = []): RoutingModule[] => {
const parseConfigHost: ts.ParseConfigHost = {
fileExists: existsSync,
readDirectory: ts.sys.readDirectory,
Expand All @@ -418,11 +418,16 @@ export const parseRoutes = (tsconfig: string): RoutingModule[] => {
const program = ts.createProgram(parsed.fileNames, parsed.options, host);
const typeChecker = program.getTypeChecker();

const toAbsolute = (file: string) => file.startsWith('/') ? file : join(process.cwd(), file);
const excludeFiles = new Set<string>(exclude.map(toAbsolute));
const visitNode = (
s: ts.SourceFile,
callback: (routeObj: ts.Node) => void,
n: ts.Node
) => {
if (excludeFiles.has(s.fileName)) {
return;
}
if (!n) {
return;
}
Expand Down

0 comments on commit 902b6d4

Please sign in to comment.