MCPcopy Index your code
hub / github.com/ampproject/amphtml / getValidatorJs

Function getValidatorJs

build-system/tasks/validate-html-fixtures.js:80–99  ·  view source on GitHub ↗

* Checks for the existence of a local wasm / js validator binary and returns * its location. Defaults to the wasm binary on the CDN. * @return {Promise }

()

Source from the content-addressed store, hash-verified

78 * @return {Promise<string>}
79 */
80async function getValidatorJs() {
81 const localWasmValidatorPath =
82 'validator/bazel-bin/cpp/engine/wasm/validator_js_bin.js';
83 const localJsValidatorPath = 'validator/dist/validator_minified.js';
84 if (await pathExists(localWasmValidatorPath)) {
85 log('Using the', cyan('locally built wasm validator') + '...');
86 return localWasmValidatorPath;
87 }
88 if (await pathExists(localJsValidatorPath)) {
89 log('Using the', cyan('locally built js validator') + '...');
90 return localJsValidatorPath;
91 }
92 log('Using the', cyan('wasm validator from the CDN') + '...');
93 logLocalDev(
94 '⤷ To use a locally built wasm or js validator,',
95 'run the build command from',
96 cyan('validator/README.md') + '.'
97 );
98 return 'https://cdn.ampproject.org/v0/validator_wasm.js'; // eslint-disable-line local/no-forbidden-terms
99}
100
101/**
102 * Runs amphtml-validator on the given list of files and prints results.

Callers 1

runCheckFunction · 0.85

Calls 3

cyanFunction · 0.85
logLocalDevFunction · 0.85
logFunction · 0.50

Tested by

no test coverage detected