Skip to content
This repository has been archived by the owner on Sep 25, 2024. It is now read-only.

Commit

Permalink
exit code is the number of errors. this is useful for github actions …
Browse files Browse the repository at this point in the history
…reporting
  • Loading branch information
randomshinichi committed Jan 21, 2024
1 parent defaac4 commit 8105f66
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import minimist from "minimist";
(async () => {
try {
const argv = minimist(process.argv.slice(2));
await validateValidatedTokensCsv(argv._[0]);
const returnCode = await validateValidatedTokensCsv(argv._[0]);
process.exit(returnCode);
}
catch (error: any) {
console.log(error.message)
Expand Down
3 changes: 2 additions & 1 deletion src/logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { indexToLineNumber } from "./utils/validate";
import { parse } from "csv-parse/sync";
import fs from "fs";

export async function validateValidatedTokensCsv(filename: string) {
export async function validateValidatedTokensCsv(filename: string): Promise<number> {
const [records, recordsRaw] = parseCsv(filename);

const recordsPreviousRaw = await gitPreviousVersion("validated-tokens.csv");
Expand All @@ -33,6 +33,7 @@ export async function validateValidatedTokensCsv(filename: string) {
console.log("Invalid Mint Addresses:", invalidMintAddresses);
console.log("Not Community Validated:", notCommunityValidated);
console.log("Edits to Existing Tokens:", noEditsAllowed);
return (duplicateSymbols + duplicateMints + attemptsToAddMultipleTokens + invalidMintAddresses + noEditsAllowed)
}

// Get previous version of validated-tokens.csv from last commit
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { validateValidatedTokensCsv } from "./logic";
// Github Actions entrypoint
(async () => {
try {
await validateValidatedTokensCsv("validated-tokens.csv");
const returnCode = await validateValidatedTokensCsv("validated-tokens.csv");
process.exit(returnCode);
}
catch (error: any) {
core.setFailed(error.message);
Expand Down

0 comments on commit 8105f66

Please sign in to comment.