Skip to content

Commit

Permalink
Merge pull request #1195 from salesforcecli/mdonnalley/ms-type-error
Browse files Browse the repository at this point in the history
fix: ms might be undefined
  • Loading branch information
shetzel authored Oct 24, 2024
2 parents 0a19755 + 1f9df69 commit 50963ee
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/commands/project/retrieve/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,12 @@ export default class RetrieveMetadata extends SfCommand<RetrieveResultJson> {
);

protected retrieveResult!: RetrieveResult;
protected ms!: MultiStageOutput<{
status: string;
apiData: RetrieveVersionData;
}>;
protected ms:
| MultiStageOutput<{
status: string;
apiData: RetrieveVersionData;
}>
| undefined;

// eslint-disable-next-line complexity
public async run(): Promise<RetrieveResultJson> {
Expand Down Expand Up @@ -222,27 +224,27 @@ export default class RetrieveMetadata extends SfCommand<RetrieveResultJson> {

if (componentSetFromNonDeletes.size !== 0 || retrieveOpts.packageOptions?.length) {
Lifecycle.getInstance().on('apiVersionRetrieve', async (apiData: RetrieveVersionData) =>
Promise.resolve(this.ms.updateData({ apiData }))
Promise.resolve(this.ms?.updateData({ apiData }))
);
const retrieve = await componentSetFromNonDeletes.retrieve(retrieveOpts);
this.ms.goto('Waiting for the org to respond', { status: 'Pending' });

retrieve.onUpdate((data) => {
this.ms.goto('Waiting for the org to respond', { status: mdTransferMessages.getMessage(data.status) });
this.ms?.goto('Waiting for the org to respond', { status: mdTransferMessages.getMessage(data.status) });
});
retrieve.onFinish((data) => {
this.ms.goto('Done', { status: mdTransferMessages.getMessage(data.response.status) });
this.ms?.goto('Done', { status: mdTransferMessages.getMessage(data.response.status) });
});
retrieve.onCancel((data) => {
this.ms.updateData({ status: mdTransferMessages.getMessage(data?.status ?? 'Canceled') });
this.ms.error();
this.ms?.updateData({ status: mdTransferMessages.getMessage(data?.status ?? 'Canceled') });
this.ms?.error();
});
retrieve.onError((error: Error) => {
if (error.message.includes('client has timed out')) {
this.ms.updateData({ status: 'Client Timeout' });
this.ms?.updateData({ status: 'Client Timeout' });
}

this.ms.error();
this.ms?.error();
throw error;
});

Expand Down Expand Up @@ -300,8 +302,8 @@ export default class RetrieveMetadata extends SfCommand<RetrieveResultJson> {

protected catch(error: Error | SfError): Promise<never> {
if (!this.jsonEnabled() && error instanceof SourceConflictError && error.data) {
this.ms.updateData({ status: 'Failed' });
this.ms.error();
this.ms?.updateData({ status: 'Failed' });
this.ms?.error();
writeConflictTable(error.data);
// set the message and add plugin-specific actions
return super.catch({
Expand All @@ -310,7 +312,7 @@ export default class RetrieveMetadata extends SfCommand<RetrieveResultJson> {
actions: messages.getMessages('error.Conflicts.Actions'),
});
} else {
this.ms.error();
this.ms?.error();
}

return super.catch(error);
Expand Down

0 comments on commit 50963ee

Please sign in to comment.