diff --git a/tools/respecDocWriter.js b/tools/respecDocWriter.js index 1bd02a23d8..cb24db2097 100644 --- a/tools/respecDocWriter.js +++ b/tools/respecDocWriter.js @@ -166,61 +166,6 @@ function isRespecScript(req) { } } -/** - * Fetches a ReSpec "src" URL, and writes the processed static HTML to an "out" path. - * @deprecated Please use `toHTML` instead. - * @param {string} src A URL or filepath that is the ReSpec source. - * @param {string | null | ""} out A path to write to. If null, goes to stdout. If "", then don't write, just return value. - * @param {object} [whenToHalt] Allowing execution to stop without writing. - * @param {boolean} [whenToHalt.haltOnError] Do not write if a ReSpec processing has an error. - * @param {boolean} [whenToHalt.haltOnWarn] Do not write if a ReSpec processing has a warning. - * @param {object} [options] - * @param {number} [options.timeout] Milliseconds before processing should timeout. - * @param {boolean} [options.disableSandbox] See https://peter.sh/experiments/chromium-command-line-switches/#no-sandbox - * @param {boolean} [options.debug] Show the Chromium window with devtools open for debugging. - * @param {boolean} [options.verbose] Log processing status to stdout. - * @param {(error: RsError) => void} [options.onError] What to do if a ReSpec processing has an error. Logs to stderr by default. - * @param {(warning: RsError) => void} [options.onWarning] What to do if a ReSpec processing has a warning. Logs to stderr by default. - * @return {Promise} Resolves with HTML when done writing. Rejects on errors. - */ -async function fetchAndWrite(src, out, whenToHalt = {}, options = {}) { - const colors = require("colors"); - colors.setTheme({ debug: "cyan", error: "red", warn: "yellow" }); - - const showError = error => console.error(colors.error(error)); - const showWarning = warning => console.warn(colors.warn(warning)); - - showWarning( - "DEPRECATION WARNING: `fetchAndWrite` is deprecated and will be removed in a future version. Please use `toHTML` instead." - ); - - const opts = { - onError(error) { - showError(`💥 ReSpec error: ${colors.debug(error.message)}`); - }, - onWarning(warning) { - showWarning(`⚠️ ReSpec warning: ${colors.debug(warning.message)}`); - }, - ...options, - devtools: options.debug, - }; - const { html, errors, warnings } = await toHTML(src, opts); - - const abortOnWarning = whenToHalt.haltOnWarn && warnings.length; - const abortOnError = whenToHalt.haltOnError && errors.length; - if (abortOnError || abortOnWarning) { - throw new Error( - `${abortOnError ? "Errors" : "Warnings"} found during processing.` - ); - } - - if (out === "") out = null; - else if (out === null) out = "stdout"; - - await write(out, html); - return html; -} - /** * @param {import("puppeteer").Page} page * @typedef {[major: number, minor: number, patch: number]} ReSpecVersion @@ -425,5 +370,4 @@ async function write(destination, html) { } exports.toHTML = toHTML; -exports.fetchAndWrite = fetchAndWrite; exports.write = write;