-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy path_sfScratchOrgDelete.js
More file actions
29 lines (23 loc) · 889 Bytes
/
_sfScratchOrgDelete.js
File metadata and controls
29 lines (23 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'use strict';
// Initialize required modules
const sfdx = require('sfdx-node/parallel');
/**
* @function _sfScratchOrgDelete
* @description Attempts to delete a given scratchOrg
*
* @param {Object} environmentDef Represents the already-validated environment details to use when performing the actions
* @returns {Promise} Returns a promise with the scratchOrg deployment results
*/
module.exports = (environmentDef) => {
// noinspection SpellCheckingInspection
const deployArguments = {
_rejectOnError: true,
noprompt: true
};
// Set the username to deploy to if it's defined
if (Object.prototype.hasOwnProperty.call(environmentDef, 'sfScratchOrgUsername')) {
deployArguments.targetusername = environmentDef.sfScratchOrgUsername;
}
// Attempt to delete to the scratchOrg
return sfdx.force.org.delete(deployArguments);
};