@@ -48,9 +48,16 @@ async function execCommandsInATask(
4848
4949 // 3. Create the batch file.
5050 const okMessage = completionMsgs || [ "Task completed successfully." ] ;
51+ // For custom completion messages we use info color since we don't know
52+ // their nature. Could also add a style attribution to the action
53+ // specification in commands.js to provide more control.
54+ const okStyle = ( completionMsgs ) ? "INFO" : "OK" ;
5155 const failMessage = "Task failed." ;
5256 const titleMessage = `${ title } ` ;
5357
58+ // The path to the apio bin so we can invoke 'apio api echo ...'.
59+ const apioBin = utils . apioBinaryPath ( ) ;
60+
5461 let shell ;
5562 let shellArgs ;
5663 if ( platforms . isWindows ( ) ) {
@@ -66,7 +73,7 @@ async function execCommandsInATask(
6673 `set "ERR=%errorlevel%"` ,
6774 `if %ERR% neq 0 (` ,
6875 ` echo.` ,
69- ` echo ${ failMessage } ` ,
76+ ` ${ apioBin } api echo -t " ${ failMessage } " -s ERROR ` ,
7077 preserveExitCode ? ` exit /b %ERR%` : ` exit /b 0` ,
7178 `)` ,
7279 ] ) ;
@@ -80,7 +87,7 @@ async function execCommandsInATask(
8087 " " ,
8188 `echo.` ,
8289 // `echo ${okMessage}`,
83- ...okMessage . map ( ( s ) => `echo ${ s } ` ) ,
90+ ...okMessage . map ( ( s ) => `${ apioBin } api echo -t " ${ s } " -s ${ okStyle } ` ) ,
8491 // ...okMessage.map((s) => makeGreenEcho(s, true)),
8592 "exit /b 0" ,
8693 ] ;
@@ -100,7 +107,7 @@ async function execCommandsInATask(
100107 `ERR=$?` ,
101108 `if [ $ERR -ne 0 ]; then` ,
102109 ` echo` ,
103- ` echo "${ failMessage } "` ,
110+ ` ${ apioBin } api echo -t "${ failMessage } " -s ERROR ` ,
104111 preserveExitCode ? ` exit $ERR` : ` exit 0` ,
105112 `fi` ,
106113 ] ) ;
@@ -113,7 +120,7 @@ async function execCommandsInATask(
113120 " " ,
114121 "echo" ,
115122 // `echo "${okMessage}"`,
116- ...okMessage . map ( ( s ) => `echo "${ s } "` ) ,
123+ ...okMessage . map ( ( s ) => `${ apioBin } api echo -t "${ s } " -s ${ okStyle } ` ) ,
117124 // ...okMessage.map((s) => makeGreenEcho(s, false)),
118125 "exit 0" ,
119126 ] ;
0 commit comments