@@ -146,6 +146,7 @@ export class MetadataDeployer extends Deployer {
146146 public async promptForUsername ( ) : Promise < string > {
147147 const aliasOrUsername = ConfigAggregator . getValue ( OrgConfigProperties . TARGET_ORG ) ?. value as string ;
148148 const stateAggregator = await StateAggregator . getInstance ( ) ;
149+ await stateAggregator . orgs . readAll ( ) ;
149150 const allAliases = stateAggregator . aliases . getAll ( ) ;
150151 let targetOrgAuth : OrgAuthorization ;
151152 // make sure the "target-org" can be used in this deploy
@@ -172,14 +173,17 @@ export class MetadataDeployer extends Deployer {
172173 }
173174 }
174175 }
176+
175177 if ( ! aliasOrUsername || targetOrgAuth ?. isExpired ) {
176- const authorizations = (
178+ const promises = (
177179 await AuthInfo . listAllAuthorizations ( ( orgAuth ) => ! orgAuth . error && orgAuth . isExpired !== true )
178- ) . map ( ( orgAuth ) => {
179- const org = stateAggregator . orgs . get ( orgAuth . username ) ;
180- const timestamp = org . timestamp ? new Date ( org . timestamp as string ) : new Date ( ) ;
180+ ) . map ( async ( orgAuth ) => {
181+ const stat = await stateAggregator . orgs . stat ( orgAuth . username ) ;
182+ const timestamp = stat ? new Date ( stat . mtimeMs ) : new Date ( ) ;
181183 return { ...orgAuth , timestamp } as OrgAuthWithTimestamp ;
182184 } ) ;
185+
186+ const authorizations = await Promise . all ( promises ) ;
183187 if ( authorizations . length > 0 ) {
184188 const newestAuths = authorizations . sort ( compareOrgs ) ;
185189 const options = newestAuths . map ( ( auth ) => ( {
0 commit comments