diff --git a/.changeset/rare-crews-attack.md b/.changeset/rare-crews-attack.md new file mode 100644 index 0000000..9a0c5ec --- /dev/null +++ b/.changeset/rare-crews-attack.md @@ -0,0 +1,5 @@ +--- +"@workleap/chromatic-ado": patch +--- + +Minor changes. diff --git a/src/bin.ts b/src/bin.ts index a0c15f7..300568b 100644 --- a/src/bin.ts +++ b/src/bin.ts @@ -33,9 +33,9 @@ async function run() { // Accepting the baseline automatically when Chromatic is executed on the "main" branch. // Running Chromatic on the "main" branch allow us to use "squash" merge for PRs, see: https://www.chromatic.com/docs/custom-ci-provider/#squashrebase-merge-and-the-main-branch. // Furthermore, changes from PR doesn't seem to be updating the baseline at all but I don't know why, it seems like a bug with ADO. - const isAutoAcceptChanges = getVariable("Build.Reason") !== "PullRequest" && getVariable("Build.SourceBranch") === "refs/heads/main"; + const isAutoAcceptingChanges = getVariable("Build.Reason") !== "PullRequest" && getVariable("Build.SourceBranch") === "refs/heads/main"; - if (isAutoAcceptChanges) { + if (isAutoAcceptingChanges) { argv.push("--auto-accept-changes", "main"); } @@ -58,8 +58,15 @@ async function run() { return; } - if (isAutoAcceptChanges) { - setResult(TaskResult.Succeeded, `${output.changeCount} changes has been automatically accepted.`); + // Chromatic will returns changes event if they are automatically accepted. + if (isAutoAcceptingChanges) { + const message = output.changeCount > 0 + ? `${output.changeCount} visual ${output.changeCount === 1 ? "change" : "changes"} has been automatically accepted.` + : ""; + + setResult(TaskResult.Succeeded, message); + + return; } const comment = `