Skip to content

Commit

Permalink
Process.exit(1) on error (#2)
Browse files Browse the repository at this point in the history
* Process.exit(1) on error

* Additional message

* Format message
  • Loading branch information
jcantosz authored Aug 7, 2023
1 parent d380ae6 commit 628b3aa
Show file tree
Hide file tree
Showing 12 changed files with 1,271 additions and 1,228 deletions.
5 changes: 3 additions & 2 deletions aad-user-sync/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58528,6 +58528,7 @@ async function getGroupsFromAzureAD(client) {

// Get the Azure AD group object for the specified group name.
async function getGroup(client, groupName) {
console.log(`Checking group "${groupName}" against Azure`);
const group = await client.api(`/groups/`).header("ConsistencyLevel", "eventual").search(`"displayName:${groupName}"`).select("id").get();
if (group.value.length > 1) {
throw new Error(`Multiple groups found with name ${groupName}`);
Expand Down Expand Up @@ -58907,14 +58908,14 @@ async function main() {
// If an error occurs, log it and continue to the next group (if configured to do so).
logError(group.displayName, error);
if (!continueOnErrors) {
break;
process.exit(1); // exit with error code
}
}
}
}

// Call the main function and log any errors.
main().catch(console.error);
main();

})();

Expand Down
4 changes: 2 additions & 2 deletions aad-user-sync/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ async function main() {
// If an error occurs, log it and continue to the next group (if configured to do so).
logError(group.displayName, error);
if (!continueOnErrors) {
break;
process.exit(1); // exit with error code
}
}
}
}

// Call the main function and log any errors.
main().catch(console.error);
main();
1 change: 1 addition & 0 deletions aad-user-sync/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ async function getGroupsFromAzureAD(client) {

// Get the Azure AD group object for the specified group name.
async function getGroup(client, groupName) {
console.log(`\tChecking group "${groupName}" exists in Azure`);
const group = await client.api(`/groups/`).header("ConsistencyLevel", "eventual").search(`"displayName:${groupName}"`).select("id").get();
if (group.value.length > 1) {
throw new Error(`Multiple groups found with name ${groupName}`);
Expand Down
4 changes: 4 additions & 0 deletions create-teams-from-directories/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ inputs:
dry_run:
description: "Prevent executing commands that would make changes to GitHub"
required: false
continue_on_errors:
description: "If errors should be ignored"
required: false
default: "false"

runs:
using: "node16"
Expand Down
Loading

0 comments on commit 628b3aa

Please sign in to comment.