11'use strict'
22
3- const { platform } = require ( 'process' )
43const { inspect } = require ( 'util' )
54
6- const { red , yellow , bold, dim, inverse } = require ( 'chalk' )
5+ const { bold, dim, inverse } = require ( 'chalk' )
76
87// Retrieve `message` which sums up all information that can be gathered about
98// the event.
@@ -14,6 +13,7 @@ const getMessage = function({
1413 secondPromiseState,
1514 secondPromiseValue,
1615 error,
16+ levelInfo,
1717} ) {
1818 const message = MESSAGES [ eventName ] ( {
1919 promiseState,
@@ -23,8 +23,7 @@ const getMessage = function({
2323 error,
2424 } )
2525
26- const level = eventName === 'warning' ? 'warn' : 'error'
27- const messageA = prettify ( { message, level, eventName } )
26+ const messageA = prettify ( { message, eventName, levelInfo } )
2827 return messageA
2928}
3029
@@ -86,11 +85,10 @@ const printValue = function(value) {
8685 return inspect ( value )
8786}
8887
89- const prettify = function ( { message, level , eventName } ) {
88+ const prettify = function ( { message, eventName , levelInfo : { COLOR , SIGN } } ) {
9089 const [ header , ...lines ] = message . split ( '\n' )
9190
9291 // Add color, icon and `eventName` to first message line.
93- const { COLOR , SIGN } = LEVELS [ level ]
9492 const headerA = COLOR ( `${ bold ( inverse ( ` ${ SIGN } ${ eventName } ` ) ) } ${ header } ` )
9593 // Add gray color and indentation to other lines.
9694 const linesA = lines . map ( line => dim ( `\t${ VERTICAL_BAR } ${ line } ` ) )
@@ -99,20 +97,6 @@ const prettify = function({ message, level, eventName }) {
9997 return messageA
10098}
10199
102- // Start the message with an icon followed by `Error` or `Warning`
103- // Also add colors
104- const isWindows = platform === 'win32'
105- const LEVELS = {
106- warn : {
107- COLOR : yellow ,
108- SIGN : isWindows ? '\u203C' : '\u26A0' ,
109- } ,
110- error : {
111- COLOR : red ,
112- SIGN : isWindows ? '\u00D7' : '\u2718' ,
113- } ,
114- }
115-
116100const VERTICAL_BAR = '\u2016'
117101
118102module . exports = {
0 commit comments