@@ -26,6 +26,8 @@ import {
2626 setOpen ,
2727 setUiPort
2828} from "../options" ;
29+ import { BsErrors } from "../bin" ;
30+ import { handleHostOption } from "./transforms/handleHostOption" ;
2931
3032const _ = require ( "../lodash.custom" ) ;
3133const defaultConfig = require ( "../default-config" ) ;
@@ -35,9 +37,13 @@ const immDefs = fromJS(defaultConfig);
3537 * @param {Object } input
3638 * @returns {Map }
3739 */
40+ export type BsTempOptions = Map < string , any > ;
41+ export type TransformResult = [ BsTempOptions , BsErrors ] ;
42+ export type TransformFn = ( subject : BsTempOptions ) => TransformResult ;
43+
3844export function merge ( input ) {
3945 const merged = immDefs . mergeDeep ( input ) ;
40- const transforms = [
46+ const transforms : TransformFn [ ] = [
4147 addToFilesOption ,
4248 addCwdToWatchOptions ,
4349 addDefaultIgnorePatterns ,
@@ -62,14 +68,17 @@ export function merge(input) {
6268 fixRewriteRules ,
6369 setMiddleware ,
6470 setOpen ,
65- setUiPort
71+ setUiPort ,
6672 ] ;
6773
68- const output = transforms . reduce ( ( acc , item ) => {
69- return item . call ( null , acc ) ;
70- } , merged ) ;
71-
72- // console.log(output.toJSON());
74+ const output = transforms . reduce (
75+ ( acc : TransformResult , item : TransformFn ) => {
76+ const [ current , currentErrors ] = acc ;
77+ const [ result , errors ] = item . call ( null , current ) ;
78+ return [ result , [ ...currentErrors , ...errors ] ] ;
79+ } ,
80+ [ merged , [ ] ] as TransformResult
81+ ) ;
7382
7483 return output ;
7584}
@@ -110,3 +119,22 @@ export function makeFilesArg(value) {
110119 objs : objs
111120 } ;
112121}
122+
123+ export function printErrors ( errors : BsErrors ) {
124+ return errors
125+ . map ( error =>
126+ [
127+ `Error Type: ${ error . type } ` ,
128+ `Error Level: ${ error . level } ` ,
129+ error . errors . map ( item =>
130+ [
131+ `Error Message: ${ item . error . message } ` ,
132+ item . meta ? item . meta ( ) . join ( "\n" ) : ""
133+ ]
134+ . filter ( Boolean )
135+ . join ( "\n" )
136+ )
137+ ] . join ( "\n" )
138+ )
139+ . join ( "\n\n" ) ;
140+ }
0 commit comments