-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy path_sfUserPermsetAssign.js
More file actions
33 lines (26 loc) · 1.1 KB
/
_sfUserPermsetAssign.js
File metadata and controls
33 lines (26 loc) · 1.1 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
'use strict';
// Initialize required modules
const sfdx = require('sfdx-node/parallel');
/**
* @function _sfUserPermsetAssign
* @description Attempts to assign the default permission-set to the scratchOrg user
*
* @param {Object} environmentDef Represents the already-validated environment details to use when performing the actions
* @param {String} permissionSetName Represents the permissionSet name to be assigned to the current user
* @returns {Promise} Returns the result of the permsetAssignment attempt
*/
module.exports = (environmentDef, permissionSetName) => {
// Initialize local variables
let deployArguments;
// Default the deployment arguments
deployArguments = {
permsetname: permissionSetName,
_rejectOnError: true
};
// Set the username to deploy to if it's defined
if (Object.prototype.hasOwnProperty.call(environmentDef, 'sfScratchOrgUsername')) {
deployArguments.targetusername = environmentDef.sfScratchOrgUsername;
}
// Attempt to assign the permission-set to the user
return sfdx.force.user.permsetAssign(deployArguments);
};