UNPKG

@socketsecurity/lib

Version:

Core utilities and infrastructure for Socket.dev security tools

92 lines (91 loc) 2.45 kB
"use strict"; /* Socket Lib - Built with esbuild */ var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var stderr_exports = {}; __export(stderr_exports, { clearLine: () => clearLine, cursorTo: () => cursorTo, getColumns: () => getColumns, getRows: () => getRows, isTTY: () => isTTY, stderr: () => stderr, writeError: () => writeError, writeErrorFormatted: () => writeErrorFormatted, writeErrorLine: () => writeErrorLine, writeStackTrace: () => writeStackTrace, writeWarning: () => writeWarning }); module.exports = __toCommonJS(stderr_exports); const stderr = process.stderr; function writeErrorLine(text = "") { stderr.write(`${text} `); } function writeError(text) { stderr.write(text); } function clearLine() { if (stderr.isTTY) { stderr.cursorTo(0); stderr.clearLine(0); } } function cursorTo(x, y) { if (stderr.isTTY) { stderr.cursorTo(x, y); } } function isTTY() { return stderr.isTTY || false; } function getColumns() { return stderr.columns || 80; } function getRows() { return stderr.rows || 24; } function writeWarning(message, prefix = "Warning") { const formatted = `${prefix}: ${message}`; writeErrorLine(formatted); } function writeErrorFormatted(message, prefix = "Error") { const formatted = `${prefix}: ${message}`; writeErrorLine(formatted); } function writeStackTrace(error) { if (error.stack) { writeErrorLine(error.stack); } else { writeErrorFormatted(error.message); } } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { clearLine, cursorTo, getColumns, getRows, isTTY, stderr, writeError, writeErrorFormatted, writeErrorLine, writeStackTrace, writeWarning });