UNPKG

@plugjs/plug

Version:
61 lines (59 loc) 2.65 kB
"use strict"; 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); // logging/github.ts var github_exports = {}; __export(github_exports, { githubAnnotation: () => githubAnnotation }); module.exports = __toCommonJS(github_exports); var import_node_os = require("node:os"); var import_node_util = require("node:util"); var import_ansi = require("../utils/ansi.cjs"); var import_options = require("./options.cjs"); var _output = import_options.logOptions.output; var _githubAnnotations = import_options.logOptions.githubAnnotations; var _inspectOptions = { ...import_options.logOptions.inspectOptions, breakLength: Infinity }; import_options.logOptions.on("changed", (options) => { _output = options.output; _githubAnnotations = options.githubAnnotations; _inspectOptions = { ...options.inspectOptions, breakLength: Infinity }; }); function escapeData(data) { return (0, import_ansi.stripAnsi)(data).replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A"); } function escapeProp(prop) { return (0, import_ansi.stripAnsi)(`${prop}`).replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A").replace(/:/g, "%3A").replace(/,/g, "%2C"); } function githubAnnotation(options, ...args) { if (!_githubAnnotations) return; if (typeof options === "string") options = { type: options }; const { type, ...parameters } = options; const attributes = Object.entries(parameters).filter(([key, value]) => !!(key && value)).map(([key, value]) => `${key}=${escapeProp(value)}`).join(","); const msg = escapeData((0, import_node_util.formatWithOptions)(_inspectOptions, ...args)); if (attributes) { _output.write(`::${type} ${attributes}::${msg}${import_node_os.EOL}`); } else { _output.write(`::${type}::${msg}${import_node_os.EOL}`); } } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { githubAnnotation }); //# sourceMappingURL=github.cjs.map