CodeCommitsIssuesPull requestsActionsInsightsSecurity
b96e14fd294a74341222ff389e283354499d0b68

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

.script/jsonFileValidator.ts

24lines · modecode

1import { runCheckOverChangedFiles } from "./utils/changedFilesValidator";
2import { ExitCode } from "./utils/exitCode";
3import fs from "fs";
4import * as logger from "./utils/logger";
5
6export async function IsValidJsonFile(filePath: string): Promise<ExitCode> {
7 JSON.parse(fs.readFileSync(filePath, "utf8"));
8 return ExitCode.SUCCESS;
9}
10
11let fileTypeSuffixes = ["json"];
12let CheckOptions = {
13 onCheckFile: (filePath: string) => {
14 return IsValidJsonFile(filePath);
15 },
16 onExecError: async (e: any, filePath: string) => {
17 console.log(`Incorrect Json file. File path: ${filePath}. Error message: ${e.message}`);
18 },
19 onFinalFailed: async () => {
20 logger.logError("An error occurred, please open an issue");
21 }
22};
23
24runCheckOverChangedFiles(CheckOptions, fileTypeSuffixes);