-
Notifications
You must be signed in to change notification settings - Fork 5
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
Showing
2 changed files
with
57 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import stripAnsi from 'strip-ansi' | ||
|
||
// Normalize Gulp output so it's predictable across time and environments | ||
export const normalizeMessage = function(message) { | ||
const messageA = stripAnsi(message) | ||
const messageB = REPLACEMENTS.reduce(replacePart, messageA) | ||
const messageC = messageB.trim() | ||
return messageC | ||
} | ||
|
||
const replacePart = function(message, [before, after]) { | ||
return message.replace(before, after) | ||
} | ||
|
||
const REPLACEMENTS = [ | ||
// File paths | ||
[/[^ (\n]+\/[^ )\n]+/gu, '/path'], | ||
// Stack traces | ||
[/ +at [^]+/gu, ' at STACK TRACE'], | ||
// Gulp shows file content that triggered an error | ||
[/[^]+Error:/gu, ''], | ||
// Timestamps | ||
[/\[\d{2}:\d{2}:\d{2}\]/gu, '[12:00:00]'], | ||
// Duration | ||
[/(\d+\.)?\d+ [μnm]s/gu, '100 ms'], | ||
// Make snapshots less verbose | ||
[/.*Working directory changed.*/gu, ''], | ||
[/.*Using gulpfile.*/gu, ''], | ||
] |
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