UNPKG

@modyo/cli

Version:

Modyo CLI Command line to expose local development tools

26 lines (25 loc) 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const promises_1 = tslib_1.__importDefault(require("node:fs/promises")); const node_path_1 = tslib_1.__importDefault(require("node:path")); const debug_1 = tslib_1.__importDefault(require("debug")); const core_1 = require("@oclif/core"); const path_exists_1 = tslib_1.__importDefault(require("../utils/path-exists")); const get_body_1 = tslib_1.__importDefault(require("./get-body")); const debug = (0, debug_1.default)('push/extract-html.ts'); async function extractHTML($, config) { core_1.ux.action.start(`Extracting${config.removeEmojis ? ' and cleaning ' : ' '}html`); const html = (0, get_body_1.default)({ $, removeEmojis: config.removeEmojis }); core_1.ux.action.stop(); if (process.env.DEBUG !== '*') { return html; } if (!(await (0, path_exists_1.default)('.debug'))) { debug('creating .debug dir'); await promises_1.default.mkdir(node_path_1.default.join('.debug')); } await promises_1.default.writeFile(node_path_1.default.resolve('.debug', 'index.html'), html, 'utf8'); return html; } exports.default = extractHTML;