Skip to content

Commit

Permalink
Fix unchained permset job
Browse files Browse the repository at this point in the history
  • Loading branch information
Stian-Schikora committed Nov 17, 2022
1 parent 6c2a7f7 commit 8013f97
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,32 +102,29 @@ export async function assignDefaultPermsets() {

//Assings all default permission sets defined in the workspace settings
export function assignPermsets(packageName?: string) {
let shellJob = assignPermsetsJob(packageName);
let jobAdded = assignPermsetsJob(packageName);

if(shellJob instanceof EXTENSION_CONTEXT) {
//If extension context is rerturned we can start the jobs
if(jobAdded === true) {
EXTENSION_CONTEXT.startJobs();
}
}

export function assignPermsetsJob(packageName?: string) {
export function assignPermsetsJob(packageName?: string): boolean {
//Get the permets to assign på default by reading json config file.
let permsets = getDefaultPermsetConfig(packageName);

if(permsets && permsets.length > 0) {
let shellJob = new Job('Assign Default Permission Sets');
permsets.forEach(permset => {
let cmd = 'sfdx force:user:permset:assign -n ' + permset;
shellJob.addJob(new Job('Assign: ' + permset, new ShellCommand(cmd)));
});
return EXTENSION_CONTEXT.addJob(shellJob);
EXTENSION_CONTEXT.addJob(shellJob);
return true;
}
else{
dxmateOutput.appendLine('No permission sets to assign');
dxmateOutput.show();
return new Promise<string>((resolve, reject) => {
resolve('No permsets to assign');
});
return false;
}
}

Expand Down

0 comments on commit 8013f97

Please sign in to comment.