Skip to content

Commit e5ab4fc

Browse files
authored
Merge pull request #53 from coderoad/feature/no-validate-build
Feature/no validate build
2 parents cd0e4e9 + 62de1ba commit e5ab4fc

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

src/build.ts

+13-4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type BuildArgs = {
2525
markdown: string;
2626
yaml: string;
2727
output: string;
28+
validate: boolean;
2829
};
2930

3031
async function build(args: string[]) {
@@ -41,6 +42,9 @@ async function build(args: string[]) {
4142
// -o --output - default coderoad.json
4243
const output =
4344
getArg(args, { name: "output", alias: "o" }) || "tutorial.json";
45+
const validate = getArg(args, { name: "validate", alias: "v" }) !== "false";
46+
47+
console.log("validate", validate);
4448

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

@@ -49,6 +53,7 @@ async function build(args: string[]) {
4953
output,
5054
markdown,
5155
yaml,
56+
validate,
5257
};
5358
} catch (e) {
5459
console.error("Error parsing build logs");
@@ -139,10 +144,14 @@ async function build(args: string[]) {
139144

140145
// validate tutorial based on tutorial json schema
141146
try {
142-
const valid = validateSchema(tutorialSchema, tutorial);
143-
if (!valid) {
144-
console.error("Tutorial validation failed. See above to see what to fix");
145-
return;
147+
if (options.validate) {
148+
const valid = validateSchema(tutorialSchema, tutorial);
149+
if (!valid) {
150+
console.error(
151+
"Tutorial validation failed. See above to see what to fix"
152+
);
153+
// continue rather than exiting early
154+
}
146155
}
147156
} catch (e) {
148157
console.error("Error validating tutorial schema:");

src/help.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ export function build() {
3232
Usage: coderoad build [path] [options]
3333
3434
Options:
35-
--help (-h) display these help docs
36-
--markdown (-m) custom path to the tutorial markdown file (TUTORIAL.md)
37-
--yaml (-y) custom path to the tutorial yaml file (coderoad.yaml)
38-
--output (-o) custom path to tutorial json config file (coderoad.json)
35+
--help (-h) display these help docs
36+
--markdown (-m) (TUTORIAL.md) custom path to the tutorial markdown file
37+
--yaml (-y) (coderoad.yaml) custom path to the tutorial yaml file
38+
--output (-o) (coderoad.json) custom path to tutorial json config file
3939
4040
More docs at https://github.com/coderoad/coderoad-cli`);
4141
}
@@ -46,8 +46,9 @@ export function validate() {
4646
Usage: coderoad validate [path] [options]
4747
4848
Options:
49-
--help (-h) display these help docs
50-
--clean (-c) set to false to preserve .tmp folder. Helpful for debugging
49+
--help (-h) display these help docs
50+
--validate (-v) (true) run tutorial schema validation. Set to false to block validation.
51+
--clean (-c) (false) set to false to preserve .tmp folder. Helpful for debugging
5152
5253
More docs at https://github.com/coderoad/coderoad-cli`);
5354
}

0 commit comments

Comments
 (0)