File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,6 +26,15 @@ export interface ProjectContext<Flags = any, Args = any> {
2626 args : Args ;
2727}
2828
29+ const headersArrayToObject = (
30+ arr : string [ ]
31+ ) : Record < string , string > | undefined => {
32+ if ( ! arr ) return ;
33+ return arr
34+ . map ( val => JSON . parse ( val ) )
35+ . reduce ( ( pre , next ) => ( { ...pre , ...next } ) , { } ) ;
36+ } ;
37+
2938const getServiceFromKey = ( key ) : string | undefined => {
3039 const [ type , service ] = key . split ( ":" ) ;
3140 if ( type === "service" ) return service ;
@@ -110,7 +119,12 @@ export abstract class ProjectCommand extends Command {
110119
111120 if ( flags . endpoint ) {
112121 config . setDefaults ( {
113- service : { endpoint : { url : flags . endpoint , headers : flags . header } }
122+ service : {
123+ endpoint : {
124+ url : flags . endpoint ,
125+ headers : headersArrayToObject ( flags . header )
126+ }
127+ }
114128 } ) ;
115129 }
116130
@@ -201,7 +215,7 @@ export abstract class ClientCommand extends ProjectCommand {
201215 if ( flags . endpoint ) {
202216 config . client . service = {
203217 url : flags . endpoint ,
204- headers : flags . headers
218+ headers : headersArrayToObject ( flags . headers )
205219 } ;
206220 }
207221 return config ;
You can’t perform that action at this time.
0 commit comments