@@ -42,34 +42,39 @@ export async function handler(argv) {
4242 inquirer . registerPrompt ( 'tree' , TreePrompt )
4343
4444 let tree = [ ]
45- for ( let item of hierarchy . children ) {
46- let children = [ ]
47- if ( item . subaccounts ) {
48- for ( let itemSub of item . subaccounts ) {
49- let child = {
50- name : `🧾 ${ itemSub . displayName } ` ,
51- value : `{"guid": "${ itemSub . guid } ", "type": "item" }` ,
52- short : `Selected: ${ itemSub . displayName } `
45+ if ( hierarchy . children ) {
46+ for ( let item of hierarchy . children ) {
47+ let children = [ ]
48+ if ( item . subaccounts ) {
49+ for ( let itemSub of item . subaccounts ) {
50+ let child = {
51+ name : `🧾 ${ itemSub . displayName } ` ,
52+ value : `{"guid": "${ itemSub . guid } ", "type": "item" }` ,
53+ short : `Selected: ${ itemSub . displayName } `
54+ }
55+ children . push ( child )
5356 }
54- children . push ( child )
57+ let leaf = {
58+ name : `📁 ${ item . displayName } ` ,
59+ value : `{"guid": "${ item . guid } ", "type": "folder" }` ,
60+ children : children
61+ }
62+ tree . push ( leaf )
5563 }
64+
65+ }
66+ }
67+ if ( hierarchy . subaccounts ) {
68+ for ( let item of hierarchy . subaccounts ) {
5669 let leaf = {
57- name : `📁 ${ item . displayName } ` ,
58- value : `{"guid": "${ item . guid } ", "type": "folder " }` ,
59- children : children
70+ name : `🧾 ${ item . displayName } ` ,
71+ value : `{"guid": "${ item . guid } ", "type": "item " }` ,
72+ short : `Selected: ${ item . displayName } `
6073 }
6174 tree . push ( leaf )
6275 }
63-
64- }
65- for ( let item of hierarchy . subaccounts ) {
66- let leaf = {
67- name : `🧾 ${ item . displayName } ` ,
68- value : `{"guid": "${ item . guid } ", "type": "item" }` ,
69- short : `Selected: ${ item . displayName } `
70- }
71- tree . push ( leaf )
7276 }
77+
7378 inquirer
7479 . prompt ( [
7580 {
0 commit comments