-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@angular-devkit/build-angular): do not print `Angular is running …
…in development mode.` in the server console when running prerender in dev mode Prior to this change `Angular is running in development mode` was printed multiple times when running prerendering in devmode.
- Loading branch information
1 parent
b2678bb
commit 3f679f1
Showing
4 changed files
with
55 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
packages/angular_devkit/build_angular/src/utils/server-rendering/utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
const IGNORED_LOGS = new Set(['Angular is running in development mode.']); | ||
const PATCHED_CONSOLE_SYMBOL = Symbol.for('Angular CLI Console Patched'); | ||
|
||
/** Method to filter a number of console.log from the output. | ||
* @returns a function that when invoked restores the default console.log behaviour. | ||
*/ | ||
export function patchConsoleToIgnoreSpecificLogs(): () => void { | ||
/* eslint-disable no-console, @typescript-eslint/no-explicit-any */ | ||
if (!(console as any)[PATCHED_CONSOLE_SYMBOL]) { | ||
const originalConsoleLog = console.log; | ||
|
||
console.log = (...args) => { | ||
if (!IGNORED_LOGS.has(args[0])) { | ||
originalConsoleLog.apply(args); | ||
} | ||
}; | ||
|
||
(console as any)[PATCHED_CONSOLE_SYMBOL] = () => { | ||
console.log = originalConsoleLog; | ||
delete (console as any)[PATCHED_CONSOLE_SYMBOL]; | ||
}; | ||
} | ||
|
||
return (console as any)[PATCHED_CONSOLE_SYMBOL]; | ||
/* eslint-enable no-console, @typescript-eslint/no-explicit-any */ | ||
} |