trustwallet-assets/script/action/json.ts
Adam R 294d8bcb5d
[internal] Fixes and Checks: separate into consistency and sanity (#3197)
* rename to sanityFix
* Infra for consistency checks and Fixes.
* Whitelist check moved to consistency check only.

Co-authored-by: Catenocrypt <catenocrypt@users.noreply.github.com>
2020-08-10 10:56:41 +02:00

40 lines
1.2 KiB
TypeScript

import { chainsPath, pricingFolderPath } from "../common/repo-structure";
import { findFiles } from "../common/filesystem";
import { ActionInterface, CheckStepInterface } from "./interface";
import { isValidJSON } from "../common/json";
import * as bluebird from "bluebird";
export class JsonAction implements ActionInterface {
getName(): string { return "Json files"; }
getSanityChecks(): CheckStepInterface[] {
return [
{
getName: () => { return "Check all JSON files to have valid content"},
check: async () => {
var error: string = "";
const files = [
...findFiles(chainsPath, 'json'),
...findFiles(pricingFolderPath, 'json')
];
await bluebird.each(files, async file => {
if (!isValidJSON(file)) {
error += `${file} path contains invalid JSON\n`;
}
});
return error;
}
},
];
}
getConsistencyChecks = null;
sanityFix = null;
consistencyFix = null;
update = null;
}