forked from paritytech/review-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created CLI for config validation (paritytech#46)
Created a very simple CLI which can validate a `review-bot.yml` config file and produce errors if it finds any. Also added a step to evaluate the config file in the CI This resolves paritytech#45
- Loading branch information
Showing
6 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/node_modules | ||
/dist | ||
/dist* | ||
.env | ||
|
||
# Editor directories and files | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { readFileSync } from "fs"; | ||
import { parse } from "yaml"; | ||
|
||
import { ConfigurationFile } from "./file/types"; | ||
import { validateConfig, validateRegularExpressions } from "./file/validator"; | ||
|
||
const fileLocation = process.argv[2]; | ||
|
||
if (!fileLocation) { | ||
throw new Error("Missing file location! Write the path as a parameter. (More info in the README)"); | ||
} | ||
|
||
console.log("Looking for config in", fileLocation); | ||
const configTxt = readFileSync(fileLocation, "utf8"); | ||
console.log("Found config file"); | ||
const config = parse(configTxt) as ConfigurationFile; | ||
|
||
const configFile = validateConfig(config); | ||
|
||
const [result, error] = validateRegularExpressions(configFile, console); | ||
if (!result) { | ||
throw new Error(`Regular expression is invalid: ${error}`); | ||
} | ||
|
||
console.log("Config is valid!"); |