Skip to content

Commit

Permalink
fix(ngdoc): should ignore watch json files #364
Browse files Browse the repository at this point in the history
  • Loading branch information
why520crazy committed Jul 31, 2022
1 parent e2b8b25 commit 3bd92ab
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions packages/ngdoc/src/ng-parser-host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ export class DefaultNgParserHost implements NgParserHost {
if (this.moduleWatchersMap.get(resolvedModule.resolvedFileName) || !resolvedModule.resolvedFileName.includes(this.rootDir)) {
return;
}
// Note: ignore json file, it will always trigger watch callback event for json file
// see https://github.com/docgeni/docgeni/issues/364
if (resolvedModule.resolvedFileName.endsWith('.json')) {
return;
}
debug(`watch resolvedModule: ${resolvedModule.resolvedFileName}`, 'ng-parser');
const watcher = toolkit.fs.watch(resolvedModule.resolvedFileName, { persistent: true }, (event: string, filename: string) => {
this.tsProgram = this.createProgram();
Expand Down
9 changes: 5 additions & 4 deletions packages/ngdoc/test/fixtures/tsconfig/src/button.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Component } from '@angular/core';
import users from './users.json';

@Component({
selector: 'button',
template: `button`
template: `
button
`
})
export class ButtonComponent {

}
export class ButtonComponent {}
1 change: 1 addition & 0 deletions packages/ngdoc/test/fixtures/tsconfig/src/users.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{}]
3 changes: 2 additions & 1 deletion packages/ngdoc/test/fixtures/tsconfig/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"compilerOptions": {
"experimentalDecorators": true
"experimentalDecorators": true,
"resolveJsonModule": true
},
// "files": ["./src/public-api.ts"]
"include": ["src/"]
Expand Down

0 comments on commit 3bd92ab

Please sign in to comment.