UNPKG

@plugjs/plug

Version:
58 lines (56 loc) 2.23 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); // utils/caller.ts var caller_exports = {}; __export(caller_exports, { findCaller: () => findCaller }); module.exports = __toCommonJS(caller_exports); var import_node_fs = require("node:fs"); var import_node_url = require("node:url"); var import_asserts = require("../asserts.cjs"); var import_logging = require("../logging.cjs"); var import_paths = require("../paths.cjs"); function findCaller(of) { const oldPrepareStackTrace = Error.prepareStackTrace; try { Error.prepareStackTrace = (_, stackTraces) => { const [stackTrace] = stackTraces; if (!stackTrace) return; const nullableFileOrUrl = stackTrace.getFileName(); if (!nullableFileOrUrl) return; const file2 = nullableFileOrUrl.startsWith("file:/") ? (0, import_node_url.fileURLToPath)(nullableFileOrUrl) : nullableFileOrUrl; (0, import_paths.assertAbsolutePath)(file2); return file2; }; const record = {}; Error.captureStackTrace(record, of); const file = record.stack; (0, import_asserts.assert)(file, "Unable to determine build file name"); (0, import_asserts.assert)((0, import_node_fs.statSync)(file).isFile(), `Build file ${(0, import_logging.$p)(file)} not found`); return file; } finally { Error.prepareStackTrace = oldPrepareStackTrace; } } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { findCaller }); //# sourceMappingURL=caller.cjs.map