Skip to content

Feature/no validate build #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type BuildArgs = {
markdown: string;
yaml: string;
output: string;
validate: boolean;
};

async function build(args: string[]) {
Expand All @@ -41,6 +42,9 @@ async function build(args: string[]) {
// -o --output - default coderoad.json
const output =
getArg(args, { name: "output", alias: "o" }) || "tutorial.json";
const validate = getArg(args, { name: "validate", alias: "v" }) !== "false";

console.log("validate", validate);

console.log(`Building CodeRoad ${output}...`);

Expand All @@ -49,6 +53,7 @@ async function build(args: string[]) {
output,
markdown,
yaml,
validate,
};
} catch (e) {
console.error("Error parsing build logs");
Expand Down Expand Up @@ -139,10 +144,14 @@ async function build(args: string[]) {

// validate tutorial based on tutorial json schema
try {
const valid = validateSchema(tutorialSchema, tutorial);
if (!valid) {
console.error("Tutorial validation failed. See above to see what to fix");
return;
if (options.validate) {
const valid = validateSchema(tutorialSchema, tutorial);
if (!valid) {
console.error(
"Tutorial validation failed. See above to see what to fix"
);
// continue rather than exiting early
}
}
} catch (e) {
console.error("Error validating tutorial schema:");
Expand Down
13 changes: 7 additions & 6 deletions src/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ export function build() {
Usage: coderoad build [path] [options]

Options:
--help (-h) display these help docs
--markdown (-m) custom path to the tutorial markdown file (TUTORIAL.md)
--yaml (-y) custom path to the tutorial yaml file (coderoad.yaml)
--output (-o) custom path to tutorial json config file (coderoad.json)
--help (-h) display these help docs
--markdown (-m) (TUTORIAL.md) custom path to the tutorial markdown file
--yaml (-y) (coderoad.yaml) custom path to the tutorial yaml file
--output (-o) (coderoad.json) custom path to tutorial json config file

More docs at https://github.com/coderoad/coderoad-cli`);
}
Expand All @@ -46,8 +46,9 @@ export function validate() {
Usage: coderoad validate [path] [options]

Options:
--help (-h) display these help docs
--clean (-c) set to false to preserve .tmp folder. Helpful for debugging
--help (-h) display these help docs
--validate (-v) (true) run tutorial schema validation. Set to false to block validation.
--clean (-c) (false) set to false to preserve .tmp folder. Helpful for debugging

More docs at https://github.com/coderoad/coderoad-cli`);
}