File tree Expand file tree Collapse file tree 4 files changed +30
-21
lines changed Expand file tree Collapse file tree 4 files changed +30
-21
lines changed Original file line number Diff line number Diff line change @@ -83,12 +83,16 @@ class CommandAuthenticate extends CommandPolykey {
83
83
this . logger . info (
84
84
`Authenticated digital identity provider ${ providerId } ` ,
85
85
) ;
86
- process . stdout . write (
87
- binUtils . outputFormatter ( {
88
- type : options . format === 'json' ? 'json' : 'list' ,
89
- data : [ message . response . identityId ] ,
90
- } ) ,
91
- ) ;
86
+ let output : string | Uint8Array ;
87
+ if ( options . format === 'json' ) {
88
+ output = binUtils . outputFormatter ( {
89
+ type : 'json' ,
90
+ data : { identityId : message . response . identityId } ,
91
+ } ) ;
92
+ } else {
93
+ output = `${ message . response . identityId } \n` ;
94
+ }
95
+ process . stdout . write ( output ) ;
92
96
} else {
93
97
never ( ) ;
94
98
}
Original file line number Diff line number Diff line change @@ -60,14 +60,16 @@ class CommandClaim extends CommandPolykey {
60
60
} ) ,
61
61
auth ,
62
62
) ;
63
- const output = [ `Claim Id: ${ claimMessage . claimId } ` ] ;
63
+ const data : { claimId : string ; url ?: string } = {
64
+ claimId : claimMessage . claimId ,
65
+ } ;
64
66
if ( claimMessage . url ) {
65
- output . push ( `Url: ${ claimMessage . url } ` ) ;
67
+ data . url = claimMessage . url ;
66
68
}
67
69
process . stdout . write (
68
70
binUtils . outputFormatter ( {
69
- type : options . format === 'json' ? 'json' : 'list ' ,
70
- data : output ,
71
+ type : options . format === 'json' ? 'json' : 'dict ' ,
72
+ data,
71
73
} ) ,
72
74
) ;
73
75
} finally {
Original file line number Diff line number Diff line change @@ -59,16 +59,19 @@ class CommandClaim extends CommandPolykey {
59
59
} ) ,
60
60
auth ,
61
61
) ;
62
- process . stdout . write (
63
- binUtils . outputFormatter ( {
64
- type : options . format === 'json' ? 'json' : 'list' ,
65
- data : [
66
- `Successfully sent Gestalt Invite notification to Keynode with ID ${ nodesUtils . encodeNodeId (
67
- nodeId ,
68
- ) } `,
69
- ] ,
70
- } ) ,
71
- ) ;
62
+ const message = `Successfully sent Gestalt Invite notification to Keynode with ID ${ nodesUtils . encodeNodeId (
63
+ nodeId ,
64
+ ) } `;
65
+ let output : string | Uint8Array ;
66
+ if ( options . format === 'json' ) {
67
+ output = binUtils . outputFormatter ( {
68
+ type : 'json' ,
69
+ data : { message } ,
70
+ } ) ;
71
+ } else {
72
+ output = `${ message } \n` ;
73
+ }
74
+ process . stdout . write ( output ) ;
72
75
} finally {
73
76
if ( pkClient ! != null ) await pkClient . stop ( ) ;
74
77
}
Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ describe('claim', () => {
94
94
} ,
95
95
) ;
96
96
expect ( exitCode ) . toBe ( 0 ) ;
97
- expect ( JSON . parse ( stdout ) ) . toEqual ( [ 'Claim Id: 0', 'Url: test.com'] ) ;
97
+ expect ( JSON . parse ( stdout ) ) . toEqual ( { claimId : ' 0', url : ' test.com' } ) ;
98
98
// Check for claim on the provider
99
99
const claim = await testProvider . getClaim (
100
100
testToken . identityId ,
You can’t perform that action at this time.
0 commit comments