UNPKG

admina

Version:

Detect root/admin/sudo and execute commands as it if available

5 lines 32.5 kB
function e(e,t){return Object.keys(t).forEach(function(r){!("default"===r||"__esModule"===r||Object.prototype.hasOwnProperty.call(e,r))&&Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r];}});}),e;}function t(e){return e&&e.__esModule?e.default:e;}function r(e,t,r,n){Object.defineProperty(e,t,{get:r,set:n,enumerable:!0,configurable:!0});}function n(e,t,r){if("function"==typeof t&&(r=t,t={}),!r){if("function"!=typeof Promise)throw TypeError("callback not provided");return new Promise(function(r,i){n(e,t||{},function(e,t){e?i(e):r(t);});});}eu(e,t||{},function(e,n){e&&("EACCES"===e.code||t&&t.ignoreErrors)&&(e=null,n=!1),r(e,n);});}function i(e,t){try{return eu.sync(e,t||{});}catch(e){if(t&&t.ignoreErrors||"EACCES"===e.code)return!1;throw e;}}function o(e,t){let r;let n=e.options.env||process.env,i=process.cwd(),o=null!=e.options.cwd,s=o&&void 0!==process.chdir&&!process.chdir.disabled;if(s)try{process.chdir(e.options.cwd);}catch(e){}try{r=el.sync(e.command,{path:n[ep({env:n})],pathExt:t?ej.delimiter:void 0});}catch(e){}finally{s&&process.chdir(i);}return r&&(r=ej.resolve(o?e.options.cwd:"",r)),r;}function s(e){return o(e)||o(e,!0);}function a(e){return e=e.replace(tN,"^$1");}function c(e,t){return e=(e=(e=`${e}`).replace(/(\\*)"/g,'$1$1\\"')).replace(/(\\*)$/,"$1$1"),e=(e=`"${e}"`).replace(tN,"^$1"),t&&(e=e.replace(tN,"^$1")),e;}function l(e){let t;let r=Buffer.alloc(150);try{t=eG.openSync(e,"r"),eG.readSync(t,r,0,150,0),eG.closeSync(t);}catch(e){}return eg(r.toString());}function d(e){e.file=ec(e);let t=e.file&&eh(e.file);return t?(e.args.unshift(e.file),e.command=t,ec(e)):e.file;}function u(e){if(!tU)return e;let t=d(e),r=!tF.test(t);if(e.options.forceShell||r){let r=tM.test(t);e.command=ej.normalize(e.command),e.command=ef(e.command),e.args=e.args.map(e=>em(e,r));let n=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${n}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0;}return e;}function p(e,t,r){t&&!Array.isArray(t)&&(r=t,t=null);let n={command:e,args:t=t?t.slice(0):[],options:r=Object.assign({},r),file:void 0,original:{command:e,args:t}};return r.shell?n:u(n);}function f(e,t){return Object.assign(Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args});}function m(e,t){if(!tD)return;let r=e.emit;e.emit=function(n,i){if("exit"===n){let n=h(i,t,"spawn");if(n)return r.call(e,"error",n);}return r.apply(e,arguments);};}function h(e,t){return tD&&1===e&&!t.file?f(t.original,"spawn"):null;}function g(e,t){return tD&&1===e&&!t.file?f(t.original,"spawnSync"):null;}function y(e,t,r){let n=ea(e,t,r),i=eB.spawn(n.command,n.args,n.options);return eb.hookChildProcess(i,n),i;}function b(e,t,r){let n=ea(e,t,r),i=eB.spawnSync(n.command,n.args,n.options);return i.error=i.error||eb.verifyENOENTSync(i.status,n),i;}function E(e){let t="string"==typeof e?"\n":"\n".charCodeAt(),r="string"==typeof e?"\r":"\r".charCodeAt();return e[e.length-1]===t&&(e=e.slice(0,-1)),e[e.length-1]===r&&(e=e.slice(0,-1)),e;}function x(e={}){let{env:t=process.env,platform:r=process.platform}=e;return"win32"!==r?"PATH":Object.keys(t).reverse().find(e=>"PATH"===e.toUpperCase())||"Path";}function v(e={}){let r;let{cwd:n=t(ek).cwd(),path:i=t(ek).env[x()],execPath:o=t(ek).execPath}=e,s=o instanceof URL?t(eN).fileURLToPath(o):o,a=n instanceof URL?t(eN).fileURLToPath(n):n,c=t(eR).resolve(a),l=[];for(;r!==c;)l.push(t(eR).join(c,"node_modules/.bin")),r=c,c=t(eR).resolve(c,"..");return l.push(t(eR).resolve(a,s,"..")),[...l,i].join(t(eR).delimiter);}function w({env:e=t(ek).env,...r}={}){let n=x({env:e={...e}});return r.path=e[n],e[n]=v(r),e;}function S(e,t,{ignoreNonConfigurable:r=!1}={}){let{name:n}=e;for(let n of Reflect.ownKeys(t))tq(e,t,n,r);return tW(e,t),tY(e,t,n),e;}function T(e){return null!==e&&"object"==typeof e&&"function"==typeof e.pipe;}function I(e){return T(e)&&!1!==e.writable&&"function"==typeof e._write&&"object"==typeof e._writableState;}function C(e){return T(e)&&!1!==e.readable&&"function"==typeof e._read&&"object"==typeof e._readableState;}function O(e){return I(e)&&C(e);}function P(e){return O(e)&&"function"==typeof e._transform;}async function A(e,t){if(!e)throw Error("Expected a stream");let{maxBuffer:r}=t={maxBuffer:1/0,...t},n=eI(t);return await new Promise((t,i)=>{let o=e=>{e&&n.getBufferedLength()<=eS.MAX_LENGTH&&(e.bufferedData=n.getBufferedValue()),i(e);};(async()=>{try{await rB(e,n),t();}catch(e){o(e);}})(),n.on("data",()=>{n.getBufferedLength()>r&&o(new rN());});}),n.getBufferedValue();}function $(e,r,n){let i;let o=ns(e,r,n),s=r2(e,r),a=r3(e,r);nn(a,o.options),rj(o.options);try{i=t(e_).spawn(o.file,o.args,o.options);}catch(r){let e=new(t(e_).ChildProcess)();return rZ(e,Promise.reject(rn({error:r,stdout:"",stderr:"",all:"",command:s,escapedCommand:a,parsed:o,timedOut:!1,isCanceled:!1,killed:!1}))),e;}let c=rz(i),l=rG(i,o.options,c),d=rL(i,o.options,l),u={isCanceled:!1};i.kill=rT.bind(null,i.kill.bind(i)),i.cancel=rA.bind(null,i,u);let p=eE(async()=>{let[{error:e,exitCode:t,signal:r,timedOut:n},c,l,p]=await rK(i,o.options,d),f=na(o.options,c),m=na(o.options,l),h=na(o.options,p);if(e||0!==t||null!==r){let c=rn({error:e,exitCode:t,signal:r,stdout:f,stderr:m,all:h,command:s,escapedCommand:a,parsed:o,timedOut:n,isCanceled:u.isCanceled||!!o.options.signal&&o.options.signal.aborted,killed:i.killed});if(!o.options.reject)return c;throw c;}return{command:s,escapedCommand:a,exitCode:0,stdout:f,stderr:m,all:h,failed:!1,timedOut:!1,isCanceled:!1,killed:!1};});return rq(i,o.options),i.all=rH(i,o.options),rk(i),rZ(i,p),i;}function G(e,r,n){let i;let o=ns(e,r,n),s=r2(e,r),a=r3(e,r);nn(a,o.options);let c=rM(o.options);try{i=t(e_).spawnSync(o.file,o.args,{...o.options,input:c});}catch(e){throw rn({error:e,stdout:"",stderr:"",all:"",command:s,escapedCommand:a,parsed:o,timedOut:!1,isCanceled:!1,killed:!1});}let l=na(o.options,i.stdout,i.error),d=na(o.options,i.stderr,i.error);if(i.error||0!==i.status||null!==i.signal){let e=rn({stdout:l,stderr:d,error:i.error,signal:i.signal,exitCode:i.status,command:s,escapedCommand:a,parsed:o,timedOut:i.error&&"ETIMEDOUT"===i.error.code,isCanceled:!1,killed:null!==i.signal});if(!o.options.reject)return e;throw e;}return{command:s,escapedCommand:a,exitCode:0,stdout:l,stderr:d,failed:!1,timedOut:!1,isCanceled:!1,killed:!1};}function j(e){function t(r,...n){if(!Array.isArray(r))return j({...e,...r});let[i,...o]=r7(r,n);return $(i,o,nl(e));}return t.sync=(t,...r)=>{if(!Array.isArray(t))throw TypeError("Please use $(options).sync`command` instead of $.sync(options)`command`.");let[n,...i]=r7(t,r);return G(n,i,nl(e));},t;}function L(e,t){let[r,...n]=r5(e);return $(r,n,t);}function R(e,t){let[r,...n]=r5(e);return G(r,n,t);}function _(e,r,n={}){r&&!Array.isArray(r)&&"object"==typeof r&&(n=r,r=[]);let i=ra(n),o=t(ek).execArgv.filter(e=>!e.startsWith("--inspect")),{nodePath:s=t(ek).execPath,nodeOptions:a=o}=n;return $(s,[...a,e,...(Array.isArray(r)?r:[])],{...n,stdin:void 0,stdout:void 0,stderr:void 0,stdio:i,shell:!1});}function k(){return null!==t(Z).sync("sudo",{nothrow:!0});}function B(){var e,t;return(null===(e=(t=process).getuid)||void 0===e?void 0:e.call(t))===0||!!process.env.CI;}function N(){return B()&&k();}function U(e){return N()?`sudo ${e}`:e;}function F(e,t=[],r=nu){return N()?R(D(e,t),r):G(e,q(t),r);}function M(e,t=[],r=nu){return N()?L(D(e,t),r):$(e,q(t),r);}function D(e,t){return`sudo ${q([e,...t]).join(" ")}`;}function q(e){return e.map(e=>`'${e}'`);}async function H(){try{return await $("fltmc"),!0;}catch{return!1;}}async function W(){if("win32"!==process.platform)return!1;try{var e;return await $("fsutil",["dirty","query",null!==(e=process.env.systemdrive)&&void 0!==e?e:""]),!0;}catch(e){if("ENOENT"===e.code)return H();return!1;}}function X(){return"win32"===process.platform?np():B();}async function K(e){if(("linux"===process.platform||"darwin"===process.platform)&&N()&&void 0!==process.env.SUDO_USER){let r=t(eG).statSync(e).isDirectory();await M("chown",[...(r?["-R"]:[]),process.env.SUDO_USER,e],nu);}}var V,Y,Z,z,J,Q,ee,et,er,en,ei,eo,es,ea,ec,el,ed,eu,ep,ef,em,eh,eg,ey,eb,eE,ex,ev,ew,eS,eT,eI,eC,eO,eP,eA,e$,eG=require("fs"),ej=require("path"),eL=require("buffer"),eR=require("path"),e_=require("child_process"),ek=require("process"),eB=require("child_process"),eN=require("url"),eU=require("os"),eF=require("assert"),eM=require("events"),eD=require("fs"),eq=require("buffer"),eH=require("stream"),eW=require("util"),eX=require("util"),eK=globalThis,eV={},eY={},eZ=eK.parcelRequireb51e;null==eZ&&((eZ=function(e){if(e in eV)return eV[e].exports;if(e in eY){var t=eY[e];delete eY[e];var r={id:e,exports:{}};return eV[e]=r,t.call(r.exports,r,r.exports),r.exports;}var n=Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n;}).register=function(e,t){eY[e]=t;},eK.parcelRequireb51e=eZ),(V=eZ.register)("ftrAD",function(e,t){function r(e,t,r){return!!(e.isSymbolicLink()||e.isFile())&&function(e,t){var r=void 0!==t.pathExt?t.pathExt:process.env.PATHEXT;if(!r||-1!==(r=r.split(";")).indexOf(""))return!0;for(var n=0;n<r.length;n++){var i=r[n].toLowerCase();if(i&&e.substr(-i.length).toLowerCase()===i)return!0;}return!1;}(t,r);}function n(e,t,n){eG.stat(e,function(i,o){n(i,!i&&r(o,e,t));});}e.exports=n,n.sync=function(e,t){return r(eG.statSync(e),e,t);};}),V("9yF3I",function(e,t){function r(e,t,r){eG.stat(e,function(e,i){r(e,!e&&n(i,t));});}function n(e,t){var r,n,i,o,s,a,c,l,d;return e.isFile()&&(r=e,n=t,i=r.mode,o=r.uid,s=r.gid,a=void 0!==n.uid?n.uid:process.getuid&&process.getuid(),c=void 0!==n.gid?n.gid:process.getgid&&process.getgid(),l=parseInt("100",8),d=parseInt("010",8),i&parseInt("001",8)||i&d&&s===c||i&l&&o===a||i&(l|d)&&0===a);}e.exports=r,r.sync=function(e,t){return n(eG.statSync(e),t);};}),V("bJALw",function(e,t){e.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"],"win32"!==process.platform&&e.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT"),"linux"===process.platform&&e.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED");}),r(Y={},"hasSudo",()=>k),r(Y,"isRoot",()=>B),r(Y,"isSudo",()=>N),r(Y,"prependSudo",()=>U),r(Y,"defaultExecOptions",()=>nu),r(Y,"execRootSync",()=>F),r(Y,"execRoot",()=>M),Z={},r(z={},"isexe",()=>tu),r(z,"sync",()=>tp),J=eG.promises;const{access:ez,appendFile:eJ,chmod:eQ,chown:e0,copyFile:e1,lchmod:e2,lchown:e3,link:e8,lstat:e5,mkdir:e9,mkdtemp:e4,open:e6,readdir:e7,readFile:te,readlink:tt,realpath:tr,rename:tn,rmdir:ti,stat:to,symlink:ts,truncate:ta,unlink:tc,utimes:tl,writeFile:td}=eG.promises,tu=async(e,t={})=>{let{ignoreErrors:r=!1}=t;try{return tf(await to(e),t);}catch(e){if(r||"EACCES"===e.code)return!1;throw e;}},tp=(e,t={})=>{let{ignoreErrors:r=!1}=t;try{return tf((0,eG.statSync)(e),t);}catch(e){if(r||"EACCES"===e.code)return!1;throw e;}},tf=(e,t)=>e.isFile()&&tm(e,t),tm=(e,t)=>{var r,n,i,o,s,a,c,l,d,u,p;let f=null!==(c=t.uid)&&void 0!==c?c:null===(r=(n=process).getuid)||void 0===r?void 0:r.call(n),m=null!==(d=null!==(l=t.groups)&&void 0!==l?l:null===(i=(o=process).getgroups)||void 0===i?void 0:i.call(o))&&void 0!==d?d:[],h=null!==(p=null!==(u=t.gid)&&void 0!==u?u:null===(s=(a=process).getgid)||void 0===s?void 0:s.call(a))&&void 0!==p?p:m[0];if(void 0===f||void 0===h)throw Error("cannot get uid or gid");let g=new Set([h,...m]),y=e.mode,b=e.uid,E=e.gid,x=parseInt("100",8),v=parseInt("010",8);return!!(y&parseInt("001",8)||y&v&&g.has(E)||y&x&&b===f||y&(x|v)&&0===f);};r(Q={},"isexe",()=>th),r(Q,"sync",()=>tg);const th=async(e,t={})=>{let{ignoreErrors:r=!1}=t;try{return tb(await to(e),e,t);}catch(e){if(r||"EACCES"===e.code)return!1;throw e;}},tg=(e,t={})=>{let{ignoreErrors:r=!1}=t;try{return tb((0,eG.statSync)(e),e,t);}catch(e){if(r||"EACCES"===e.code)return!1;throw e;}},ty=(e,t)=>{let{pathExt:r=process.env.PATHEXT||""}=t,n=r.split(";");if(-1!==n.indexOf(""))return!0;for(let t=0;t<n.length;t++){let r=n[t].toLowerCase(),i=e.substring(e.length-r.length).toLowerCase();if(r&&i===r)return!0;}return!1;},tb=(e,t,r)=>e.isFile()&&ty(t,r),tE=process.env._ISEXE_TEST_PLATFORM_||process.platform,tx="win32"===tE?Q:z,tv=tx.isexe,tw=tx.sync;ee=tv,et=tw,er=ej.join,en=ej.delimiter,ei=ej.sep,eo=ej.posix;const tS="win32"===process.platform,tT=new RegExp(`[${eo.sep}${ei===eo.sep?"":ei}]`.replace(/(\\)/g,"\\$1")),tI=RegExp(`^\\.${tT.source}`),tC=e=>Object.assign(Error(`not found: ${e}`),{code:"ENOENT"}),tO=(e,{path:t=process.env.PATH,pathExt:r=process.env.PATHEXT,delimiter:n=en})=>{let i=e.match(tT)?[""]:[...(tS?[process.cwd()]:[]),...(t||"").split(n)];if(tS){let t=r||[".EXE",".CMD",".BAT",".COM"].join(n),o=t.split(n).flatMap(e=>[e,e.toLowerCase()]);return e.includes(".")&&""!==o[0]&&o.unshift(""),{pathEnv:i,pathExt:o,pathExtExe:t};}return{pathEnv:i,pathExt:[""]};},tP=(e,t)=>{let r=/^".*"$/.test(e)?e.slice(1,-1):e;return(!r&&tI.test(t)?t.slice(0,2):"")+er(r,t);},tA=async(e,t={})=>{let{pathEnv:r,pathExt:n,pathExtExe:i}=tO(e,t),o=[];for(let s of r){let r=tP(s,e);for(let e of n){let n=r+e;if(await ee(n,{pathExt:i,ignoreErrors:!0})){if(!t.all)return n;o.push(n);}}}if(t.all&&o.length)return o;if(t.nothrow)return null;throw tC(e);},t$=(e,t={})=>{let{pathEnv:r,pathExt:n,pathExtExe:i}=tO(e,t),o=[];for(let s of r){let r=tP(s,e);for(let e of n){let n=r+e;if(et(n,{pathExt:i,ignoreErrors:!0})){if(!t.all)return n;o.push(n);}}}if(t.all&&o.length)return o;if(t.nothrow)return null;throw tC(e);};Z=tA,tA.sync=t$,es={},ea={},ec={},el={};const tG="win32"===process.platform||"cygwin"===process.env.OSTYPE||"msys"===process.env.OSTYPE,tj=tG?";":":";ed={},eu=eZ("win32"===process.platform||eK.TESTING_WINDOWS?"ftrAD":"9yF3I"),ed=n,n.sync=i;const tL=e=>Object.assign(Error(`not found: ${e}`),{code:"ENOENT"}),tR=(e,t)=>{let r=t.colon||tj,n=e.match(/\//)||tG&&e.match(/\\/)?[""]:[...(tG?[process.cwd()]:[]),...(t.path||process.env.PATH||"").split(r)],i=tG?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",o=tG?i.split(r):[""];return tG&&-1!==e.indexOf(".")&&""!==o[0]&&o.unshift(""),{pathEnv:n,pathExt:o,pathExtExe:i};},t_=(e,t,r)=>{"function"==typeof t&&(r=t,t={}),t||(t={});let{pathEnv:n,pathExt:i,pathExtExe:o}=tR(e,t),s=[],a=r=>new Promise((i,o)=>{if(r===n.length)return t.all&&s.length?i(s):o(tL(e));let a=n[r],l=/^".*"$/.test(a)?a.slice(1,-1):a,d=ej.join(l,e);i(c(!l&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d,r,0));}),c=(e,r,n)=>new Promise((l,d)=>{if(n===i.length)return l(a(r+1));let u=i[n];ed(e+u,{pathExt:o},(i,o)=>{if(!i&&o){if(!t.all)return l(e+u);s.push(e+u);}return l(c(e,r,n+1));});});return r?a(0).then(e=>r(null,e),r):a(0);},tk=(e,t)=>{let{pathEnv:r,pathExt:n,pathExtExe:i}=tR(e,t=t||{}),o=[];for(let s=0;s<r.length;s++){let a=r[s],c=/^".*"$/.test(a)?a.slice(1,-1):a,l=ej.join(c,e),d=!c&&/^\.[\\\/]/.test(e)?e.slice(0,2)+l:l;for(let e=0;e<n.length;e++){let r=d+n[e];try{if(ed.sync(r,{pathExt:i})){if(!t.all)return r;o.push(r);}}catch(e){}}}if(t.all&&o.length)return o;if(t.nothrow)return null;throw tL(e);};el=t_,t_.sync=tk,ep={};const tB=(e={})=>{let t=e.env||process.env;return"win32"!==(e.platform||process.platform)?"PATH":Object.keys(t).reverse().find(e=>"PATH"===e.toUpperCase())||"Path";};(ep=tB).default=tB,ec=s;const tN=/([()\][%!^"`<>&|;, *?])/g;ef=a,em=c,eh={},eg={},ey={},ey=/^#!(.*)/,eg=(e="")=>{let t=e.match(ey);if(!t)return null;let[r,n]=t[0].replace(/#! ?/,"").split(" "),i=r.split("/").pop();return"env"===i?n:n?`${i} ${n}`:i;},eh=l;const tU="win32"===process.platform,tF=/\.(?:com|exe)$/i,tM=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;ea=p,eb={};const tD="win32"===process.platform;eb={hookChildProcess:m,verifyENOENT:h,verifyENOENTSync:g,notFoundError:f},(es=y).spawn=y,es.sync=b,es._parse=ea,es._enoent=eb;const tq=(e,t,r,n)=>{if("length"===r||"prototype"===r||"arguments"===r||"caller"===r)return;let i=Object.getOwnPropertyDescriptor(e,r),o=Object.getOwnPropertyDescriptor(t,r);(tH(i,o)||!n)&&Object.defineProperty(e,r,o);},tH=function(e,t){return void 0===e||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value);},tW=(e,t)=>{let r=Object.getPrototypeOf(t);r!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,r);},tX=(e,t)=>`/* Wrapped ${e}*/ ${t}`,tK=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),tV=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),tY=(e,t,r)=>{let n=""===r?"":`with ${r.trim()}() `,i=tX.bind(null,n,t.toString());Object.defineProperty(i,"name",tV),Object.defineProperty(e,"toString",{...tK,value:i});},tZ=new WeakMap(),tz=(e,t={})=>{let r;if("function"!=typeof e)throw TypeError("Expected a function");let n=0,i=e.displayName||e.name||"<anonymous>",o=function(...s){if(tZ.set(o,++n),1===n)r=e.apply(this,s),e=null;else if(!0===t.throw)throw Error(`Function \`${i}\` can only be called once`);return r;};return S(o,e),tZ.set(o,n),o;};tz.callCount=e=>{if(!tZ.has(e))throw Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return tZ.get(e);},eE=tz;const tJ=()=>Array.from({length:t1-t0+1},tQ),tQ=(e,t)=>({name:`SIGRT${t+1}`,number:t0+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),t0=34,t1=64,t2=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}],t3=()=>[...t2,...tJ()].map(t8),t8=({name:e,number:t,description:r,action:n,forced:i=!1,standard:o})=>{let{signals:{[e]:s}}=eU.constants,a=void 0!==s;return{name:e,number:a?s:t,description:r,supported:a,action:n,forced:i,standard:o};},t5=()=>Object.fromEntries(t3().map(t9)),t9=({name:e,number:t,description:r,supported:n,action:i,forced:o,standard:s})=>[e,{name:e,number:t,description:r,supported:n,action:i,forced:o,standard:s}],t4=t5(),t6=()=>{let e=t3();return Object.assign({},...Array.from({length:t1+1},(t,r)=>t7(r,e)));},t7=(e,t)=>{let r=re(e,t);if(void 0===r)return{};let{name:n,description:i,supported:o,action:s,forced:a,standard:c}=r;return{[e]:{name:n,number:e,description:i,supported:o,action:s,forced:a,standard:c}};},re=(e,t)=>{let r=t.find(({name:t})=>eU.constants.signals[t]===e);return void 0!==r?r:t.find(t=>t.number===e);},rt=t6(),rr=({timedOut:e,timeout:t,errorCode:r,signal:n,signalDescription:i,exitCode:o,isCanceled:s})=>e?`timed out after ${t} milliseconds`:s?"was canceled":void 0!==r?`failed with ${r}`:void 0!==n?`was killed with ${n} (${i})`:void 0!==o?`failed with exit code ${o}`:"failed",rn=({stdout:e,stderr:r,all:n,error:i,signal:o,exitCode:s,command:a,escapedCommand:c,timedOut:l,isCanceled:d,killed:u,parsed:{options:{timeout:p,cwd:f=t(ek).cwd()}}})=>{s=null===s?void 0:s;let m=void 0===(o=null===o?void 0:o)?void 0:t4[o].description,h=rr({timedOut:l,timeout:p,errorCode:i&&i.code,signal:o,signalDescription:m,exitCode:s,isCanceled:d}),g=`Command ${h}: ${a}`,y="[object Error]"===Object.prototype.toString.call(i),b=y?`${g} ${i.message}`:g,E=[b,r,e].filter(Boolean).join("\n");return y?(i.originalMessage=i.message,i.message=E):i=Error(E),i.shortMessage=b,i.command=a,i.escapedCommand=c,i.exitCode=s,i.signal=o,i.signalDescription=m,i.stdout=e,i.stderr=r,i.cwd=f,void 0!==n&&(i.all=n),"bufferedData"in i&&delete i.bufferedData,i.failed=!0,i.timedOut=!!l,i.isCanceled=d,i.killed=u&&!l,i;},ri=["stdin","stdout","stderr"],ro=e=>ri.some(t=>void 0!==e[t]),rs=e=>{if(!e)return;let{stdio:t}=e;if(void 0===t)return ri.map(t=>e[t]);if(ro(e))throw Error(`It's not possible to provide \`stdio\` in combination with one of ${ri.map(e=>`\`${e}\``).join(", ")}`);if("string"==typeof t)return t;if(!Array.isArray(t))throw TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof t}\``);return Array.from({length:Math.max(t.length,ri.length)},(e,r)=>t[r]);},ra=e=>{let t=rs(e);return"ipc"===t?"ipc":void 0===t||"string"==typeof t?[t,t,t,"ipc"]:t.includes("ipc")?t:[...t,"ipc"];};ex={},ev=eK.process;const rc=function(e){return e&&"object"==typeof e&&"function"==typeof e.removeListener&&"function"==typeof e.emit&&"function"==typeof e.reallyExit&&"function"==typeof e.listeners&&"function"==typeof e.kill&&"number"==typeof e.pid&&"function"==typeof e.on;};if(rc(ev)){var rl,rd=eF,ru=eZ("bJALw"),rp=/^win/i.test(ev.platform),rf=eM;"function"!=typeof rf&&(rf=rf.EventEmitter),ev.__signal_exit_emitter__?rl=ev.__signal_exit_emitter__:((rl=ev.__signal_exit_emitter__=new rf()).count=0,rl.emitted={}),rl.infinite||(rl.setMaxListeners(1/0),rl.infinite=!0);var rm=function(){ry&&rc(eK.process)&&(ry=!1,ru.forEach(function(e){try{ev.removeListener(e,rg[e]);}catch(e){}}),ev.emit=rv,ev.reallyExit=rE,rl.count-=1);};(ex=function(e,t){if(!rc(eK.process))return function(){};rd.equal(typeof e,"function","a callback must be provided for exit handler"),!1===ry&&rb();var r="exit";return t&&t.alwaysLast&&(r="afterexit"),rl.on(r,e),function(){rl.removeListener(r,e),0===rl.listeners("exit").length&&0===rl.listeners("afterexit").length&&rm();};}).unload=rm;var rh=function(e,t,r){rl.emitted[e]||(rl.emitted[e]=!0,rl.emit(e,t,r));},rg={};ru.forEach(function(e){rg[e]=function(){rc(eK.process)&&ev.listeners(e).length===rl.count&&(rm(),rh("exit",null,e),rh("afterexit",null,e),rp&&"SIGHUP"===e&&(e="SIGINT"),ev.kill(ev.pid,e));};}),ex.signals=function(){return ru;};var ry=!1,rb=function(){!ry&&rc(eK.process)&&(ry=!0,rl.count+=1,ru=ru.filter(function(e){try{return ev.on(e,rg[e]),!0;}catch(e){return!1;}}),ev.emit=rw,ev.reallyExit=rx);};ex.load=rb;var rE=ev.reallyExit,rx=function(e){rc(eK.process)&&(ev.exitCode=e||0,rh("exit",ev.exitCode,null),rh("afterexit",ev.exitCode,null),rE.call(ev,ev.exitCode));},rv=ev.emit,rw=function(e,t){if(!("exit"===e&&rc(eK.process)))return rv.apply(this,arguments);void 0!==t&&(ev.exitCode=t);var r=rv.apply(this,arguments);return rh("exit",ev.exitCode,null),rh("afterexit",ev.exitCode,null),r;};}else ex=function(){return function(){};};const rS=5e3,rT=(e,t="SIGTERM",r={})=>{let n=e(t);return rI(e,t,r,n),n;},rI=(e,t,r,n)=>{if(!rC(t,r,n))return;let i=setTimeout(()=>{e("SIGKILL");},rP(r));i.unref&&i.unref();},rC=(e,{forceKillAfterTimeout:t},r)=>rO(e)&&!1!==t&&r,rO=e=>e===t(eU).constants.signals.SIGTERM||"string"==typeof e&&"SIGTERM"===e.toUpperCase(),rP=({forceKillAfterTimeout:e=!0})=>{if(!0===e)return 5e3;if(!Number.isFinite(e)||e<0)throw TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);return e;},rA=(e,t)=>{e.kill()&&(t.isCanceled=!0);},r$=(e,t,r)=>{e.kill(t),r(Object.assign(Error("Timed out"),{timedOut:!0,signal:t}));},rG=(e,{timeout:t,killSignal:r="SIGTERM"},n)=>{let i;return 0===t||void 0===t?n:Promise.race([new Promise((n,o)=>{i=setTimeout(()=>{r$(e,r,o);},t);}),n.finally(()=>{clearTimeout(i);})]);},rj=({timeout:e})=>{if(void 0!==e&&(!Number.isFinite(e)||e<0))throw TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);},rL=async(e,{cleanup:r,detached:n},i)=>{if(!r||n)return i;let o=t(ex)(()=>{e.kill();});return i.finally(()=>{o();});},rR=e=>e instanceof e_.ChildProcess&&"function"==typeof e.then,r_=(e,t,r)=>{if("string"==typeof r)return e[t].pipe((0,eD.createWriteStream)(r)),e;if(I(r))return e[t].pipe(r),e;if(!rR(r))throw TypeError("The second argument must be a string, a stream or an Execa child process.");if(!I(r.stdin))throw TypeError("The target child process's stdin must be available.");return e[t].pipe(r.stdin),r;},rk=e=>{null!==e.stdout&&(e.pipeStdout=r_.bind(void 0,e,"stdout")),null!==e.stderr&&(e.pipeStderr=r_.bind(void 0,e,"stderr")),void 0!==e.all&&(e.pipeAll=r_.bind(void 0,e,"all"));};ew={},eS=eq.constants,eT=eW.promisify,eI={},eC=eH.PassThrough,eI=e=>{let{array:t}=e={...e},{encoding:r}=e,n="buffer"===r,i=!1;t?i=!(r||n):r=r||"utf8",n&&(r=null);let o=new eC({objectMode:i});r&&o.setEncoding(r);let s=0,a=[];return o.on("data",e=>{a.push(e),i?s=a.length:s+=e.length;}),o.getBufferedValue=()=>t?a:n?Buffer.concat(a,s):a.join(""),o.getBufferedLength=()=>s,o;};const rB=eT(eH.pipeline);class rN extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError";}}(ew=A).buffer=(e,t)=>A(e,{...t,encoding:"buffer"}),ew.array=(e,t)=>A(e,{...t,array:!0}),ew.MaxBufferError=rN,eO={},eP=eH.PassThrough,eO=function(){function e(i){return Array.isArray(i)?i.forEach(e):(r.push(i),i.once("end",t.bind(null,i)),i.once("error",n.emit.bind(n,"error")),i.pipe(n,{end:!1})),this;}function t(e){!(r=r.filter(function(t){return t!==e;})).length&&n.readable&&n.end();}var r=[],n=new eP({objectMode:!0});return n.setMaxListeners(0),n.add=e,n.isEmpty=function(){return 0==r.length;},n.on("unpipe",t),Array.prototype.slice.call(arguments).forEach(e),n;};const rU=e=>{if(void 0!==e)throw TypeError("The `input` and `inputFile` options cannot be both set.");},rF=({input:e,inputFile:t})=>"string"!=typeof t?e:(rU(e),(0,eD.readFileSync)(t)),rM=e=>{let t=rF(e);if(T(t))throw TypeError("The `input` option cannot be a stream in sync mode");return t;},rD=({input:e,inputFile:t})=>"string"!=typeof t?e:(rU(e),(0,eD.createReadStream)(t)),rq=(e,t)=>{let r=rD(t);void 0!==r&&(T(r)?r.pipe(e.stdin):e.stdin.end(r));},rH=(e,{all:r})=>{if(!r||!e.stdout&&!e.stderr)return;let n=t(eO)();return e.stdout&&n.add(e.stdout),e.stderr&&n.add(e.stderr),n;},rW=async(e,t)=>{if(e&&void 0!==t){e.destroy();try{return await t;}catch(e){return e.bufferedData;}}},rX=(e,{encoding:r,buffer:n,maxBuffer:i})=>{if(e&&n)return r?t(ew)(e,{encoding:r,maxBuffer:i}):t(ew).buffer(e,{maxBuffer:i});},rK=async({stdout:e,stderr:t,all:r},{encoding:n,buffer:i,maxBuffer:o},s)=>{let a=rX(e,{encoding:n,buffer:i,maxBuffer:o}),c=rX(t,{encoding:n,buffer:i,maxBuffer:o}),l=rX(r,{encoding:n,buffer:i,maxBuffer:2*o});try{return await Promise.all([s,a,c,l]);}catch(n){return Promise.all([{error:n,signal:n.signal,timedOut:n.timedOut},rW(e,a),rW(t,c),rW(r,l)]);}},rV=(async()=>{})().constructor.prototype,rY=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(rV,e)]),rZ=(e,t)=>{for(let[r,n]of rY){let i="function"==typeof t?(...e)=>Reflect.apply(n.value,t(),e):n.value.bind(t);Reflect.defineProperty(e,r,{...n,value:i});}},rz=e=>new Promise((t,r)=>{e.on("exit",(e,r)=>{t({exitCode:e,signal:r});}),e.on("error",e=>{r(e);}),e.stdin&&e.stdin.on("error",e=>{r(e);});}),rJ=(e,t=[])=>Array.isArray(t)?[e,...t]:[e],rQ=/^[\w.-]+$/,r0=/"/g,r1=e=>"string"!=typeof e||rQ.test(e)?e:`"${e.replace(r0,'\\"')}"`,r2=(e,t)=>rJ(e,t).join(" "),r3=(e,t)=>rJ(e,t).map(e=>r1(e)).join(" "),r8=/ +/g,r5=e=>{let t=[];for(let r of e.trim().split(r8)){let e=t[t.length-1];e&&e.endsWith("\\")?t[t.length-1]=`${e.slice(0,-1)} ${r}`:t.push(r);}return t;},r9=e=>{let t=typeof e;if("string"===t)return e;if("number"===t)return String(e);if("object"===t&&null!==e&&!(e instanceof e_.ChildProcess)&&"stdout"in e){let t=typeof e.stdout;if("string"===t)return e.stdout;if((0,eL.Buffer).isBuffer(e.stdout))return e.stdout.toString();throw TypeError(`Unexpected "${t}" stdout in template expression`);}throw TypeError(`Unexpected "${t}" in template expression`);},r4=(e,t,r)=>r||0===e.length||0===t.length?[...e,...t]:[...e.slice(0,-1),`${e[e.length-1]}${t[0]}`,...t.slice(1)],r6=({templates:e,expressions:t,tokens:r,index:n,template:i})=>{let o=null!=i?i:e.raw[n],s=r4(r,o.split(r8).filter(Boolean),o.startsWith(" "));if(n===t.length)return s;let a=t[n];return r4(s,Array.isArray(a)?a.map(e=>r9(e)):[r9(a)],o.endsWith(" "));},r7=(e,t)=>{let r=[];for(let[n,i]of e.entries())r=r6({templates:e,expressions:t,tokens:r,index:n,template:i});return r;},ne=(0,eX.debuglog)("execa").enabled,nt=(e,t)=>String(e).padStart(t,"0"),nr=()=>{let e=new Date();return`${nt(e.getHours(),2)}:${nt(e.getMinutes(),2)}:${nt(e.getSeconds(),2)}.${nt(e.getMilliseconds(),3)}`;},nn=(e,{verbose:r})=>{r&&t(ek).stderr.write(`[${nr()}] ${e} `);},ni=1e8,no=({env:e,extendEnv:r,preferLocal:n,localDir:i,execPath:o})=>{let s=r?{...t(ek).env,...e}:e;return n?w({env:s,cwd:i,execPath:o}):s;},ns=(e,r,n={})=>{let i=t(es)._parse(e,r,n);return e=i.command,r=i.args,(n={maxBuffer:1e8,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:(n=i.options).cwd||t(ek).cwd(),execPath:t(ek).execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:ne,...n}).env=no(n),n.stdio=rs(n),"win32"===t(ek).platform&&"cmd"===t(eR).basename(e,".exe")&&r.unshift("/q"),{file:e,args:r,options:n,parsed:i};},na=(e,t,r)=>"string"==typeof t||(0,eL.Buffer).isBuffer(t)?e.stripFinalNewline?E(t):t:void 0===r?void 0:"",nc=({input:e,inputFile:t,stdio:r})=>void 0===e&&void 0===t&&void 0===r?{stdin:"inherit"}:{},nl=(e={})=>({preferLocal:!0,...nc(e),...e}),nd=j(),nu={stdio:"inherit",shell:!0};r(eA={},"isAdminWindows",()=>np),r(eA,"isAdminPosix",()=>nf),r(eA,"isAdmin",()=>X);const np=W,nf=B;r(e$={},"grantUserWriteAccess",()=>K),e(module.exports,Y),e(module.exports,eA),e(module.exports,e$); //# sourceMappingURL=index.node.cjs.map