Skip to content

Commit 090b706

Browse files
committed
Do not output error if no errors
1 parent f3d8833 commit 090b706

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

scripts/check_changeset.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ async function parseChangesetFile(changesetFile: string) {
8484
}
8585

8686
async function main() {
87-
let formattedStatusError: string = '';
88-
let missingPackagesError: string = '';
87+
const errors = [];
8988
try {
9089
await exec('yarn changeset status');
9190
} catch (e) {
9291
const messageLines = e.message.replace(/🦋 error /g, '').split('\n');
93-
formattedStatusError = '- Changeset formatting error in following file:%0A';
92+
let formattedStatusError =
93+
'- Changeset formatting error in following file:%0A';
9494
formattedStatusError += ' ```%0A';
9595
formattedStatusError += messageLines
9696
.filter(
@@ -101,6 +101,7 @@ async function main() {
101101
.map((line: string) => ` ${line}`)
102102
.join('%0A');
103103
formattedStatusError += '%0A ```%0A';
104+
errors.push(formattedStatusError);
104105
/**
105106
* Sets Github Actions output for a step. Pass changeset error message to next
106107
* step. See:
@@ -127,7 +128,7 @@ async function main() {
127128
}
128129
missingPackagesLines.push('');
129130
missingPackagesLines.push(' Make sure this was intentional.');
130-
missingPackagesError = missingPackagesLines.join('%0A');
131+
errors.push(missingPackagesLines.join('%0A'));
131132
}
132133
}
133134
} catch (e) {
@@ -140,12 +141,10 @@ async function main() {
140141
* step. See:
141142
* https://github.com/actions/toolkit/blob/master/docs/commands.md#set-outputs
142143
*/
143-
console.log(
144-
`::set-output name=CHANGESET_ERROR_MESSAGE::${[
145-
formattedStatusError,
146-
missingPackagesError
147-
].join('%0A')}`
148-
);
144+
if (errors.length > 0)
145+
console.log(
146+
`::set-output name=CHANGESET_ERROR_MESSAGE::${errors.join('%0A')}`
147+
);
149148
process.exit();
150149
}
151150

0 commit comments

Comments
 (0)