-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9293b4b
commit 19d302d
Showing
5 changed files
with
35 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
export const directivePrefix = 'wp'; | ||
|
||
export const isDebug = | ||
typeof SCRIPT_DEBUG !== 'undefined' && SCRIPT_DEBUG === true; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const logged = new Set(); | ||
|
||
export const warn = ( message ) => { | ||
// @ts-expect-error | ||
if ( typeof SCRIPT_DEBUG !== 'undefined' && SCRIPT_DEBUG === true ) { | ||
if ( logged.has( message ) ) { | ||
return; | ||
} | ||
|
||
// eslint-disable-next-line no-console | ||
console.warn( message ); | ||
|
||
// Adding a stack trace to the warning message to help with debugging. | ||
try { | ||
throw Error( message ); | ||
} catch ( e ) { | ||
// Do nothing. | ||
} | ||
logged.add( message ); | ||
} | ||
}; |
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