-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(validate/input-markup): add option to validate input markup (#157)
Co-authored-by: Sid Vishnoi <[email protected]>
- Loading branch information
1 parent
91a0055
commit f3998bb
Showing
8 changed files
with
70 additions
and
3 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
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,28 @@ | ||
import { env, exit, install, sh, yesOrNo } from "./utils.js"; | ||
|
||
import { ProcessedInput } from "./prepare.js"; | ||
type Input = Pick<ProcessedInput["build"], "source">; | ||
|
||
if (module === require.main) { | ||
if (yesOrNo(env("INPUTS_VALIDATE_INPUT_MARKUP")) === false) { | ||
exit("Skipped", 0); | ||
} | ||
|
||
const input: Input = JSON.parse(env("INPUTS_BUILD")); | ||
main(input).catch(err => exit(err.message || "Failed", err.code)); | ||
} | ||
|
||
export default async function main({ source }: Input) { | ||
console.log(`Validating ${source}...`); | ||
await install("vnu-jar"); | ||
const vnuJar = require("vnu-jar"); | ||
|
||
try { | ||
await sh(`java -jar "${vnuJar}" ${source}`, { | ||
output: "stream", | ||
}); | ||
exit("✅ Looks good! No HTML validation errors!", 0); | ||
} catch { | ||
exit("❌ Not so good... please fix the issues above."); | ||
} | ||
} |
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,14 @@ | ||
import main from "../src/validate-input-markup.js"; | ||
import { Outputs } from "./index.test.js"; | ||
|
||
export default async function validateInputMarkup(outputs: Outputs) { | ||
const { input_markup: shouldValidate = false } = | ||
outputs?.prepare?.validate || {}; | ||
if (shouldValidate === false) { | ||
return; | ||
} | ||
|
||
const { source } = outputs?.prepare?.build || { source: "index.html" }; | ||
|
||
return await main({ source }); | ||
} |