Skip to content

Instantly share code, notes, and snippets.

@vyuvalv
Created November 3, 2019 10:53
Show Gist options
  • Save vyuvalv/b7377a3ef416d3f81bd24e340fb99887 to your computer and use it in GitHub Desktop.
Save vyuvalv/b7377a3ef416d3f81bd24e340fb99887 to your computer and use it in GitHub Desktop.
Build and Run SFDX Commands with Yo parameters
// command builder
let sfdxCommand = ' sfdx force:org:create';
sfdxCommand += ' -d ' + this.props.numberOfDays; // --durationdays
sfdxCommand += ' -a ' + this.props.scratchOrgName; // --setalias
// will receieve this.options as input parameters from constructor
sfdxCommand += ' -f ' + this.options.projectFolder + '/config/scratch-org-def.json'; // --definitionfile
sfdxCommand += ' -v ' + this.options.devhubOrg; // -v | --targetdevhubusername
// will only assign as default if user wish to
if(this.props.isDefault)
sfdxCommand += ' --setdefaultusername'; // -s | --setdefaultusername
// running the SFDX command and checking if was executed successfully
this.log(" Run command : "+ chalk.magenta(sfdxCommand) );
if(shell.exec(sfdxCommand).code === 0) {
this.log('😺 ' + chalk.green('created successfully scratch org ' + this.props.scratchOrgName + '\n') );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment