Skip to content

Commit

Permalink
cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
glomotion committed May 24, 2024
1 parent 916c88d commit 26c0f16
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 28 deletions.
9 changes: 2 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13436,7 +13436,7 @@ function getAssetsIgnoreFiles(sourceArray, ignoreArray) {
}
return sourceArray;
}
const getErrorCommentBody = (_a) => __awaiter(void 0, [_a], void 0, function* ({ count, thresholdSize, invalidFiles, ignoreArray, }) {
const getErrorCommentBody = (count, thresholdSize, invalidFiles, ignoreArray) => __awaiter(void 0, void 0, void 0, function* () {
return `:warning: **Oh Snap!**, You have \`${count}\` image asset(s) with a file-size of more than \`${thresholdSize}Kb\`.
If it's not possible to optimize the below assets, you can add them into a \`.assets-ignore\` file in the root of your repository.

Expand Down Expand Up @@ -13500,12 +13500,7 @@ function main() {
const successBody = getSuccessCommentBody({
thresholdSize: inputs.thresholdSize,
});
const errorBody = yield getErrorCommentBody({
count,
thresholdSize: inputs.thresholdSize,
invalidFiles,
ignoreArray,
});
const errorBody = yield getErrorCommentBody(count, inputs.thresholdSize, invalidFiles, ignoreArray);
yield removePreviousBotComments(octokit, owner, repo, issueNumber);
const checkSuccess = count === 0;
octokit.rest.issues.createComment({
Expand Down
7 changes: 1 addition & 6 deletions dist/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ export declare function renderCommentBody(isSuccess: boolean, successBody: strin
export declare function removePreviousBotComments(octokit: Octokit, owner: string, repo: string, issueNumber: number): Promise<void>;
export declare function getIgnoreArray(): string[];
export declare function getAssetsIgnoreFiles(sourceArray: string[], ignoreArray: string[]): string[];
export declare const getErrorCommentBody: ({ count, thresholdSize, invalidFiles, ignoreArray, }: {
count: number;
thresholdSize: string;
invalidFiles: string[];
ignoreArray: string[];
}) => Promise<string>;
export declare const getErrorCommentBody: (count: number, thresholdSize: string, invalidFiles: string[], ignoreArray: string[]) => Promise<string>;
export declare const getSuccessCommentBody: ({ thresholdSize, }: {
thresholdSize: string;
}) => string;
2 changes: 1 addition & 1 deletion dist/utils.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ async function main() {
const successBody = getSuccessCommentBody({
thresholdSize: inputs.thresholdSize,
});
const errorBody = await getErrorCommentBody({
const errorBody = await getErrorCommentBody(
count,
thresholdSize: inputs.thresholdSize,
inputs.thresholdSize,
invalidFiles,
ignoreArray,
});
);

await removePreviousBotComments(octokit, owner, repo, issueNumber);

Expand Down
17 changes: 6 additions & 11 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,12 @@ export function getAssetsIgnoreFiles(
return sourceArray;
}

export const getErrorCommentBody = async ({
count,
thresholdSize,
invalidFiles,
ignoreArray,
}: {
count: number;
thresholdSize: string;
invalidFiles: string[];
ignoreArray: string[];
}) => `:warning: **Oh Snap!**, You have \`${count}\` image asset(s) with a file-size of more than \`${thresholdSize}Kb\`.
export const getErrorCommentBody = async (
count: number,
thresholdSize: string,
invalidFiles: string[],
ignoreArray: string[],
) => `:warning: **Oh Snap!**, You have \`${count}\` image asset(s) with a file-size of more than \`${thresholdSize}Kb\`.
If it's not possible to optimize the below assets, you can add them into a \`.assets-ignore\` file in the root of your repository.
**NOTE:** If you are using Biome [image](https://immutable.atlassian.net/wiki/spaces/DS/pages/2547024003/Optimising+images+for+the+web#How-BIOME-makes-working-with-images-easier) components to display these assets, and you are not opting out of their default functionality, you can safely ignore this warning - as these images will be optimized on-the-fly by our AWS Image Resizer infrastructure. More details [here](https://immutable.atlassian.net/wiki/spaces/DS/pages/2547024003/Optimising+images+for+the+web#How-BIOME-makes-working-with-images-easier).
Expand Down

0 comments on commit 26c0f16

Please sign in to comment.