11var endOfLine = require ( 'os' ) . EOL ;
22
3- var outputResult = function ( status , results , errors ) {
3+ var outputResult = function ( status , results , errors , preventExit ) {
44 process . stdout . write ( status ) ;
55 process . stdout . write ( endOfLine ) ;
66
@@ -24,8 +24,9 @@ var outputResult = function (status, results, errors) {
2424 process . stdout . write ( endOfLine ) ;
2525 }
2626 }
27-
28- throw "Unsupported result output" ;
27+ else {
28+ throw "Unsupported result output" ;
29+ }
2930 }
3031
3132 if ( errors ) {
@@ -37,26 +38,34 @@ var outputResult = function (status, results, errors) {
3738 for ( var errorIndex = 0 ; errorIndex < errors . length ; errorIndex ++ ) {
3839 var error = errors [ errorIndex ] ;
3940 if ( typeof error !== 'string' ) {
40- throw "Unsupported result output" ;
41+ throw "Unsupported error output" ;
4142 }
4243
4344 process . stdout . write ( error ) ;
4445 process . stdout . write ( endOfLine ) ;
4546 }
4647 }
48+ else if ( errors . toString ) {
49+ process . stdout . write ( errors . toString ( ) ) ;
50+ process . stdout . write ( endOfLine ) ;
51+ }
4752 else {
4853 process . stdout . write ( errors ) ;
4954 process . stdout . write ( endOfLine ) ;
5055 }
5156 }
57+
58+ if ( ! preventExit ) {
59+ process . exit ( ) ;
60+ }
5261}
5362
5463var outputSuccess = function ( results ) {
5564 outputResult ( "success" , results ) ;
5665}
5766
58- var outputCustom = function ( status , results ) {
59- outputResult ( status , results ) ;
67+ var outputCustom = function ( status , results , preventExit ) {
68+ outputResult ( status , results , undefined , preventExit ) ;
6069}
6170
6271var outputError = function ( errors ) {
0 commit comments