Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Commit

Permalink
fix(validate): fix Scratch Orgs not getting deleted after validation,…
Browse files Browse the repository at this point in the history
… when fetched from a pool

fix #838
  • Loading branch information
azlam-abdulsalam committed Feb 11, 2022
1 parent 03d6d97 commit 200ed50
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
6 changes: 4 additions & 2 deletions packages/sfp-cli/src/impl/sfdxwrappers/OrgDelete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ export default class OrgDelete extends SFDXCommand
}

getGeneratedParams(): string {

return ` --targetusername ${this.aliasOrUsername} -p`
let params = ` --targetusername ${this.aliasOrUsername} -p`;
if(this.devHubUserName)
params+=` --targetdevhubusername= ${this.devHubUserName}`
return params;
}

}
15 changes: 7 additions & 8 deletions packages/sfpowerscripts-cli/src/impl/validate/ValidateImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import SFPStatsSender from "@dxatscale/sfpowerscripts.core/lib/stats/SFPStatsSen
import ScratchOrgInfoFetcher from "../../impl/pool/services/fetchers/ScratchOrgInfoFetcher";
import Component from "@dxatscale/sfpowerscripts.core/lib/dependency/Component";
import ValidateResult from "./ValidateResult";
import PoolOrgDeleteImpl from "../pool/PoolOrgDeleteImpl";

export enum ValidateMode {
ORG,
Expand Down Expand Up @@ -149,7 +150,7 @@ export default class ValidateImpl {
return {deploymentResult, dependencyViolations};
} finally {
if (this.props.isDeleteScratchOrg) {
this.deleteScratchOrg(scratchOrgUsername);
await this.deleteScratchOrg(scratchOrgUsername);
} else {
fs.writeFileSync(
".env",
Expand Down Expand Up @@ -194,17 +195,15 @@ export default class ValidateImpl {
this.printClosingLoggingGroup();
}

private deleteScratchOrg(scratchOrgUsername: string): void {
private async deleteScratchOrg(scratchOrgUsername: string) {
try {
if (scratchOrgUsername && this.props.hubOrg.getUsername() ) {
console.log(`Deleting scratch org`, scratchOrgUsername);
child_process.execSync(
`sfdx force:org:delete -p -u ${scratchOrgUsername} -v ${this.props.hubOrg.getUsername()}`,
{
stdio: 'inherit',
encoding: 'utf8'
}
let poolOrgDeleteImpl = new PoolOrgDeleteImpl(
this.props.hubOrg,
scratchOrgUsername
);
await poolOrgDeleteImpl.execute();
}
} catch (error) {
console.log(COLOR_WARNING(error.message));
Expand Down

0 comments on commit 200ed50

Please sign in to comment.