-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy path_sfScratchOrgCreate.js
More file actions
39 lines (36 loc) · 1.29 KB
/
_sfScratchOrgCreate.js
File metadata and controls
39 lines (36 loc) · 1.29 KB
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
30
31
32
33
34
35
36
37
38
39
'use strict';
// Initialize constants
const config = require('config');
const sfdx = require('sfdx-node/parallel');
/**
* @private
* @function _geScratchOrgProfile
* @description Helper function to generate the profile-instance
*
* @param {String} profileName Represents the profile name to leverage
* @return {String} Returns the profile path-name for the scratchOrg being created
*/
const geScratchOrgProfile = profileName =>
config.get('sfScratchOrg.profilePath').toString().replace('{{profileName}}', profileName);
/**
* @function _sfScratchOrgCreate
* @description Attempts to create a SFDX scratch org
*
* @param {Object} environmentDef Represents the already-validated environment details to use when performing the actions
* @returns {Promise} Returns the result of the scratchOrg creation request
*/
module.exports = environmentDef => sfdx.force.org.create({
setalias: environmentDef.sfScratchOrgAlias,
setdefaultusername: environmentDef.sfScratchOrgSetDefault,
durationdays: environmentDef.sfScratchOrgDurationDays,
definitionfile: geScratchOrgProfile(environmentDef.sfScratchOrgProfile),
_rejectOnError: true
}).then(result => {
return {
outputDisplay: {
orgId: result.orgId,
username: result.username
},
result
};
});