UNPKG

@modern-js/module-tools

Version:

Simple, powerful, high-performance modern npm package development solution.

1 lines 3 kB
(()=>{var e={580:(e,t,r)=>{var i=global.process;const processOk=function(e){return e&&typeof e==="object"&&typeof e.removeListener==="function"&&typeof e.emit==="function"&&typeof e.reallyExit==="function"&&typeof e.listeners==="function"&&typeof e.kill==="function"&&typeof e.pid==="number"&&typeof e.on==="function"};if(!processOk(i)){e.exports=function(){return function(){}}}else{var n=r(491);var o=r(357);var a=/^win/i.test(i.platform);var f=r(361);if(typeof f!=="function"){f=f.EventEmitter}var l;if(i.__signal_exit_emitter__){l=i.__signal_exit_emitter__}else{l=i.__signal_exit_emitter__=new f;l.count=0;l.emitted={}}if(!l.infinite){l.setMaxListeners(Infinity);l.infinite=true}e.exports=function(e,t){if(!processOk(global.process)){return function(){}}n.equal(typeof e,"function","a callback must be provided for exit handler");if(p===false){_()}var r="exit";if(t&&t.alwaysLast){r="afterexit"}var remove=function(){l.removeListener(r,e);if(l.listeners("exit").length===0&&l.listeners("afterexit").length===0){s()}};l.on(r,e);return remove};var s=function unload(){if(!p||!processOk(global.process)){return}p=false;o.forEach((function(e){try{i.removeListener(e,c[e])}catch(e){}}));i.emit=d;i.reallyExit=x;l.count-=1};e.exports.unload=s;var u=function emit(e,t,r){if(l.emitted[e]){return}l.emitted[e]=true;l.emit(e,t,r)};var c={};o.forEach((function(e){c[e]=function listener(){if(!processOk(global.process)){return}var t=i.listeners(e);if(t.length===l.count){s();u("exit",null,e);u("afterexit",null,e);if(a&&e==="SIGHUP"){e="SIGINT"}i.kill(i.pid,e)}}}));e.exports.signals=function(){return o};var p=false;var _=function load(){if(p||!processOk(global.process)){return}p=true;l.count+=1;o=o.filter((function(e){try{i.on(e,c[e]);return true}catch(e){return false}}));i.emit=I;i.reallyExit=v};e.exports.load=_;var x=i.reallyExit;var v=function processReallyExit(e){if(!processOk(global.process)){return}i.exitCode=e||0;u("exit",i.exitCode,null);u("afterexit",i.exitCode,null);x.call(i,i.exitCode)};var d=i.emit;var I=function processEmit(e,t){if(e==="exit"&&processOk(global.process)){if(t!==undefined){i.exitCode=t}var r=d.apply(this,arguments);u("exit",i.exitCode,null);u("afterexit",i.exitCode,null);return r}else{return d.apply(this,arguments)}}}},357:e=>{e.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];if(process.platform!=="win32"){e.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT")}if(process.platform==="linux"){e.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")}},491:e=>{"use strict";e.exports=require("assert")},361:e=>{"use strict";e.exports=require("events")}};var t={};function __nccwpck_require__(r){var i=t[r];if(i!==undefined){return i.exports}var n=t[r]={exports:{}};var o=true;try{e[r](n,n.exports,__nccwpck_require__);o=false}finally{if(o)delete t[r]}return n.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var r=__nccwpck_require__(580);module.exports=r})();