UNPKG

go-get-folder-size

Version:

Get the size of a folder by recursively iterating through all its sub(files && folders). Use go, so high-speed

8 lines (7 loc) 30.4 kB
"use strict";var pt=Object.defineProperty;var ht=(e,t,n)=>t in e?pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var P=(e,t,n)=>(ht(e,typeof t!="symbol"?t+"":t,n),n),V=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)};var l=(e,t,n)=>(V(e,t,"read from private field"),n?n.call(e):t.get(e)),w=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},I=(e,t,n,r)=>(V(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);var X=(e,t,n)=>(V(e,t,"access private method"),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const gt=require("buffer"),S=require("path"),D=require("child_process"),E=require("process"),R=require("fs"),Le=require("url"),ke=require("node:os"),oe=require("os"),yt=require("timers/promises"),bt=require("stream"),St=require("util"),_e=require("./index-3c0f4283.js"),wt=require("readline");var Et=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Fe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var G={exports:{}},Y,Ee;function xt(){if(Ee)return Y;Ee=1,Y=r,r.sync=i;var e=R;function t(o,s){var a=s.pathExt!==void 0?s.pathExt:process.env.PATHEXT;if(!a||(a=a.split(";"),a.indexOf("")!==-1))return!0;for(var c=0;c<a.length;c++){var u=a[c].toLowerCase();if(u&&o.substr(-u.length).toLowerCase()===u)return!0}return!1}function n(o,s,a){return!o.isSymbolicLink()&&!o.isFile()?!1:t(s,a)}function r(o,s,a){e.stat(o,function(c,u){a(c,c?!1:n(u,o,s))})}function i(o,s){return n(e.statSync(o),o,s)}return Y}var Z,xe;function Tt(){if(xe)return Z;xe=1,Z=t,t.sync=n;var e=R;function t(o,s,a){e.stat(o,function(c,u){a(c,c?!1:r(u,s))})}function n(o,s){return r(e.statSync(o),s)}function r(o,s){return o.isFile()&&i(o,s)}function i(o,s){var a=o.mode,c=o.uid,u=o.gid,d=s.uid!==void 0?s.uid:process.getuid&&process.getuid(),m=s.gid!==void 0?s.gid:process.getgid&&process.getgid(),f=parseInt("100",8),p=parseInt("010",8),g=parseInt("001",8),b=f|p,x=a&g||a&p&&u===m||a&f&&c===d||a&b&&d===0;return x}return Z}var z;process.platform==="win32"||Et.TESTING_WINDOWS?z=xt():z=Tt();var It=ce;ce.sync=vt;function ce(e,t,n){if(typeof t=="function"&&(n=t,t={}),!n){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(r,i){ce(e,t||{},function(o,s){o?i(o):r(s)})})}z(e,t||{},function(r,i){r&&(r.code==="EACCES"||t&&t.ignoreErrors)&&(r=null,i=!1),n(r,i)})}function vt(e,t){try{return z.sync(e,t||{})}catch(n){if(t&&t.ignoreErrors||n.code==="EACCES")return!1;throw n}}const C=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Me=S,Pt=C?";":":",Ue=It,De=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),ze=(e,t)=>{const n=t.colon||Pt,r=e.match(/\//)||C&&e.match(/\\/)?[""]:[...C?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(n)],i=C?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",o=C?i.split(n):[""];return C&&e.indexOf(".")!==-1&&o[0]!==""&&o.unshift(""),{pathEnv:r,pathExt:o,pathExtExe:i}},qe=(e,t,n)=>{typeof t=="function"&&(n=t,t={}),t||(t={});const{pathEnv:r,pathExt:i,pathExtExe:o}=ze(e,t),s=[],a=u=>new Promise((d,m)=>{if(u===r.length)return t.all&&s.length?d(s):m(De(e));const f=r[u],p=/^".*"$/.test(f)?f.slice(1,-1):f,g=Me.join(p,e),b=!p&&/^\.[\\\/]/.test(e)?e.slice(0,2)+g:g;d(c(b,u,0))}),c=(u,d,m)=>new Promise((f,p)=>{if(m===i.length)return f(a(d+1));const g=i[m];Ue(u+g,{pathExt:o},(b,x)=>{if(!b&&x)if(t.all)s.push(u+g);else return f(u+g);return f(c(u,d,m+1))})});return n?a(0).then(u=>n(null,u),n):a(0)},Ct=(e,t)=>{t=t||{};const{pathEnv:n,pathExt:r,pathExtExe:i}=ze(e,t),o=[];for(let s=0;s<n.length;s++){const a=n[s],c=/^".*"$/.test(a)?a.slice(1,-1):a,u=Me.join(c,e),d=!c&&/^\.[\\\/]/.test(e)?e.slice(0,2)+u:u;for(let m=0;m<r.length;m++){const f=d+r[m];try{if(Ue.sync(f,{pathExt:i}))if(t.all)o.push(f);else return f}catch{}}}if(t.all&&o.length)return o;if(t.nothrow)return null;throw De(e)};var At=qe;qe.sync=Ct;var ue={exports:{}};const We=(e={})=>{const t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(r=>r.toUpperCase()==="PATH")||"Path"};ue.exports=We;ue.exports.default=We;var $t=ue.exports;const Te=S,Ot=At,Gt=$t;function Ie(e,t){const n=e.options.env||process.env,r=process.cwd(),i=e.options.cwd!=null,o=i&&process.chdir!==void 0&&!process.chdir.disabled;if(o)try{process.chdir(e.options.cwd)}catch{}let s;try{s=Ot.sync(e.command,{path:n[Gt({env:n})],pathExt:t?Te.delimiter:void 0})}catch{}finally{o&&process.chdir(r)}return s&&(s=Te.resolve(i?e.options.cwd:"",s)),s}function Rt(e){return Ie(e)||Ie(e,!0)}var Bt=Rt,le={};const se=/([()\][%!^"`<>&|;, *?])/g;function Nt(e){return e=e.replace(se,"^$1"),e}function jt(e,t){return e=`${e}`,e=e.replace(/(\\*)"/g,'$1$1\\"'),e=e.replace(/(\\*)$/,"$1$1"),e=`"${e}"`,e=e.replace(se,"^$1"),t&&(e=e.replace(se,"^$1")),e}le.command=Nt;le.argument=jt;var Lt=/^#!(.*)/;const kt=Lt;var _t=(e="")=>{const t=e.match(kt);if(!t)return null;const[n,r]=t[0].replace(/#! ?/,"").split(" "),i=n.split("/").pop();return i==="env"?r:r?`${i} ${r}`:i};const Q=R,Ft=_t;function Mt(e){const n=Buffer.alloc(150);let r;try{r=Q.openSync(e,"r"),Q.readSync(r,n,0,150,0),Q.closeSync(r)}catch{}return Ft(n.toString())}var Ut=Mt;const Dt=S,ve=Bt,Pe=le,zt=Ut,qt=process.platform==="win32",Wt=/\.(?:com|exe)$/i,Ht=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function Kt(e){e.file=ve(e);const t=e.file&&zt(e.file);return t?(e.args.unshift(e.file),e.command=t,ve(e)):e.file}function Vt(e){if(!qt)return e;const t=Kt(e),n=!Wt.test(t);if(e.options.forceShell||n){const r=Ht.test(t);e.command=Dt.normalize(e.command),e.command=Pe.command(e.command),e.args=e.args.map(o=>Pe.argument(o,r));const i=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${i}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}function Xt(e,t,n){t&&!Array.isArray(t)&&(n=t,t=null),t=t?t.slice(0):[],n=Object.assign({},n);const r={command:e,args:t,options:n,file:void 0,original:{command:e,args:t}};return n.shell?r:Vt(r)}var Yt=Xt;const de=process.platform==="win32";function fe(e,t){return Object.assign(new Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function Zt(e,t){if(!de)return;const n=e.emit;e.emit=function(r,i){if(r==="exit"){const o=He(i,t);if(o)return n.call(e,"error",o)}return n.apply(e,arguments)}}function He(e,t){return de&&e===1&&!t.file?fe(t.original,"spawn"):null}function Qt(e,t){return de&&e===1&&!t.file?fe(t.original,"spawnSync"):null}var Jt={hookChildProcess:Zt,verifyENOENT:He,verifyENOENTSync:Qt,notFoundError:fe};const Ke=D,me=Yt,pe=Jt;function Ve(e,t,n){const r=me(e,t,n),i=Ke.spawn(r.command,r.args,r.options);return pe.hookChildProcess(i,r),i}function en(e,t,n){const r=me(e,t,n),i=Ke.spawnSync(r.command,r.args,r.options);return i.error=i.error||pe.verifyENOENTSync(i.status,r),i}G.exports=Ve;G.exports.spawn=Ve;G.exports.sync=en;G.exports._parse=me;G.exports._enoent=pe;var tn=G.exports;const nn=Fe(tn);function rn(e){const t=typeof e=="string"?` `:` `.charCodeAt(),n=typeof e=="string"?"\r":"\r".charCodeAt();return e[e.length-1]===t&&(e=e.slice(0,-1)),e[e.length-1]===n&&(e=e.slice(0,-1)),e}function Xe(e={}){const{env:t=process.env,platform:n=process.platform}=e;return n!=="win32"?"PATH":Object.keys(t).reverse().find(r=>r.toUpperCase()==="PATH")||"Path"}function on(e={}){const{cwd:t=E.cwd(),path:n=E.env[Xe()],execPath:r=E.execPath}=e;let i;const o=t instanceof URL?Le.fileURLToPath(t):t;let s=S.resolve(o);const a=[];for(;i!==s;)a.push(S.join(s,"node_modules/.bin")),i=s,s=S.resolve(s,"..");return a.push(S.resolve(o,r,"..")),[...a,n].join(S.delimiter)}function sn({env:e=E.env,...t}={}){e={...e};const n=Xe({env:e});return t.path=e[n],e[n]=on(t),e}const an=(e,t,n,r)=>{if(n==="length"||n==="prototype"||n==="arguments"||n==="caller")return;const i=Object.getOwnPropertyDescriptor(e,n),o=Object.getOwnPropertyDescriptor(t,n);!cn(i,o)&&r||Object.defineProperty(e,n,o)},cn=function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},un=(e,t)=>{const n=Object.getPrototypeOf(t);n!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,n)},ln=(e,t)=>`/* Wrapped ${e}*/ ${t}`,dn=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),fn=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),mn=(e,t,n)=>{const r=n===""?"":`with ${n.trim()}() `,i=ln.bind(null,r,t.toString());Object.defineProperty(i,"name",fn),Object.defineProperty(e,"toString",{...dn,value:i})};function pn(e,t,{ignoreNonConfigurable:n=!1}={}){const{name:r}=e;for(const i of Reflect.ownKeys(t))an(e,t,i,n);return un(e,t),mn(e,t,r),e}const q=new WeakMap,Ye=(e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let n,r=0;const i=e.displayName||e.name||"<anonymous>",o=function(...s){if(q.set(o,++r),r===1)n=e.apply(this,s),e=null;else if(t.throw===!0)throw new Error(`Function \`${i}\` can only be called once`);return n};return pn(o,e),q.set(o,r),o};Ye.callCount=e=>{if(!q.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return q.get(e)};const hn=()=>{const e=Qe-Ze+1;return Array.from({length:e},gn)},gn=(e,t)=>({name:`SIGRT${t+1}`,number:Ze+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),Ze=34,Qe=64,yn=[{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"}],Je=()=>{const e=hn();return[...yn,...e].map(bn)},bn=({name:e,number:t,description:n,action:r,forced:i=!1,standard:o})=>{const{signals:{[e]:s}}=ke.constants,a=s!==void 0;return{name:e,number:a?s:t,description:n,supported:a,action:r,forced:i,standard:o}},Sn=()=>{const e=Je();return Object.fromEntries(e.map(wn))},wn=({name:e,number:t,description:n,supported:r,action:i,forced:o,standard:s})=>[e,{name:e,number:t,description:n,supported:r,action:i,forced:o,standard:s}],En=Sn(),xn=()=>{const e=Je(),t=Qe+1,n=Array.from({length:t},(r,i)=>Tn(i,e));return Object.assign({},...n)},Tn=(e,t)=>{const n=In(e,t);if(n===void 0)return{};const{name:r,description:i,supported:o,action:s,forced:a,standard:c}=n;return{[e]:{name:r,number:e,description:i,supported:o,action:s,forced:a,standard:c}}},In=(e,t)=>{const n=t.find(({name:r})=>ke.constants.signals[r]===e);return n!==void 0?n:t.find(r=>r.number===e)};xn();const vn=({timedOut:e,timeout:t,errorCode:n,signal:r,signalDescription:i,exitCode:o,isCanceled:s})=>e?`timed out after ${t} milliseconds`:s?"was canceled":n!==void 0?`failed with ${n}`:r!==void 0?`was killed with ${r} (${i})`:o!==void 0?`failed with exit code ${o}`:"failed",Ce=({stdout:e,stderr:t,all:n,error:r,signal:i,exitCode:o,command:s,escapedCommand:a,timedOut:c,isCanceled:u,killed:d,parsed:{options:{timeout:m,cwd:f=E.cwd()}}})=>{o=o===null?void 0:o,i=i===null?void 0:i;const p=i===void 0?void 0:En[i].description,g=r&&r.code,x=`Command ${vn({timedOut:c,timeout:m,errorCode:g,signal:i,signalDescription:p,exitCode:o,isCanceled:u})}: ${s}`,B=Object.prototype.toString.call(r)==="[object Error]",N=B?`${x} ${r.message}`:x,j=[N,t,e].filter(Boolean).join(` `);return B?(r.originalMessage=r.message,r.message=j):r=new Error(j),r.shortMessage=N,r.command=s,r.escapedCommand=a,r.exitCode=o,r.signal=i,r.signalDescription=p,r.stdout=e,r.stderr=t,r.cwd=f,n!==void 0&&(r.all=n),"bufferedData"in r&&delete r.bufferedData,r.failed=!0,r.timedOut=!!c,r.isCanceled=u,r.killed=d&&!c,r},M=["stdin","stdout","stderr"],Pn=e=>M.some(t=>e[t]!==void 0),Cn=e=>{if(!e)return;const{stdio:t}=e;if(t===void 0)return M.map(r=>e[r]);if(Pn(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${M.map(r=>`\`${r}\``).join(", ")}`);if(typeof t=="string")return t;if(!Array.isArray(t))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof t}\``);const n=Math.max(t.length,M.length);return Array.from({length:n},(r,i)=>t[i])},A=[];A.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&A.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&A.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");const U=e=>!!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",J=Symbol.for("signal-exit emitter"),ee=globalThis,An=Object.defineProperty.bind(Object);class $n{constructor(){P(this,"emitted",{afterExit:!1,exit:!1});P(this,"listeners",{afterExit:[],exit:[]});P(this,"count",0);P(this,"id",Math.random());if(ee[J])return ee[J];An(ee,J,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(t,n){this.listeners[t].push(n)}removeListener(t,n){const r=this.listeners[t],i=r.indexOf(n);i!==-1&&(i===0&&r.length===1?r.length=0:r.splice(i,1))}emit(t,n,r){if(this.emitted[t])return!1;this.emitted[t]=!0;let i=!1;for(const o of this.listeners[t])i=o(n,r)===!0||i;return t==="exit"&&(i=this.emit("afterExit",n,r)||i),i}}class et{}const On=e=>({onExit(t,n){return e.onExit(t,n)},load(){return e.load()},unload(){return e.unload()}});class Gn extends et{onExit(){return()=>{}}load(){}unload(){}}var W,y,h,$,O,v,T,H,tt,K,nt;class Rn extends et{constructor(n){super();w(this,H);w(this,K);w(this,W,ae.platform==="win32"?"SIGINT":"SIGHUP");w(this,y,new $n);w(this,h,void 0);w(this,$,void 0);w(this,O,void 0);w(this,v,{});w(this,T,!1);I(this,h,n),I(this,v,{});for(const r of A)l(this,v)[r]=()=>{const i=l(this,h).listeners(r);let{count:o}=l(this,y);const s=n;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(o+=s.__signal_exit_emitter__.count),i.length===o){this.unload();const a=l(this,y).emit("exit",null,r),c=r==="SIGHUP"?l(this,W):r;a||n.kill(n.pid,c)}};I(this,O,n.reallyExit),I(this,$,n.emit)}onExit(n,r){if(!U(l(this,h)))return()=>{};l(this,T)===!1&&this.load();const i=r!=null&&r.alwaysLast?"afterExit":"exit";return l(this,y).on(i,n),()=>{l(this,y).removeListener(i,n),l(this,y).listeners.exit.length===0&&l(this,y).listeners.afterExit.length===0&&this.unload()}}load(){if(!l(this,T)){I(this,T,!0),l(this,y).count+=1;for(const n of A)try{const r=l(this,v)[n];r&&l(this,h).on(n,r)}catch{}l(this,h).emit=(n,...r)=>X(this,K,nt).call(this,n,...r),l(this,h).reallyExit=n=>X(this,H,tt).call(this,n)}}unload(){l(this,T)&&(I(this,T,!1),A.forEach(n=>{const r=l(this,v)[n];if(!r)throw new Error("Listener not defined for signal: "+n);try{l(this,h).removeListener(n,r)}catch{}}),l(this,h).emit=l(this,$),l(this,h).reallyExit=l(this,O),l(this,y).count-=1)}}W=new WeakMap,y=new WeakMap,h=new WeakMap,$=new WeakMap,O=new WeakMap,v=new WeakMap,T=new WeakMap,H=new WeakSet,tt=function(n){return U(l(this,h))?(l(this,h).exitCode=n||0,l(this,y).emit("exit",l(this,h).exitCode,null),l(this,O).call(l(this,h),l(this,h).exitCode)):0},K=new WeakSet,nt=function(n,...r){const i=l(this,$);if(n==="exit"&&U(l(this,h))){typeof r[0]=="number"&&(l(this,h).exitCode=r[0]);const o=i.call(l(this,h),n,...r);return l(this,y).emit("exit",l(this,h).exitCode,null),o}else return i.call(l(this,h),n,...r)};const ae=globalThis.process,{onExit:Bn,load:Dr,unload:zr}=On(U(ae)?new Rn(ae):new Gn),Nn=1e3*5,jn=(e,t="SIGTERM",n={})=>{const r=e(t);return Ln(e,t,n,r),r},Ln=(e,t,n,r)=>{if(!kn(t,n,r))return;const i=Fn(n),o=setTimeout(()=>{e("SIGKILL")},i);o.unref&&o.unref()},kn=(e,{forceKillAfterTimeout:t},n)=>_n(e)&&t!==!1&&n,_n=e=>e===oe.constants.signals.SIGTERM||typeof e=="string"&&e.toUpperCase()==="SIGTERM",Fn=({forceKillAfterTimeout:e=!0})=>{if(e===!0)return Nn;if(!Number.isFinite(e)||e<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);return e},Mn=(e,t)=>{e.kill()&&(t.isCanceled=!0)},Un=(e,t,n)=>{e.kill(t),n(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},Dn=(e,{timeout:t,killSignal:n="SIGTERM"},r)=>{if(t===0||t===void 0)return r;let i;const o=new Promise((a,c)=>{i=setTimeout(()=>{Un(e,n,c)},t)}),s=r.finally(()=>{clearTimeout(i)});return Promise.race([o,s])},zn=({timeout:e})=>{if(e!==void 0&&(!Number.isFinite(e)||e<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`)},qn=async(e,{cleanup:t,detached:n},r)=>{if(!t||n)return r;const i=Bn(()=>{e.kill()});return r.finally(()=>{i()})};function rt(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}function Ae(e){return rt(e)&&e.writable!==!1&&typeof e._write=="function"&&typeof e._writableState=="object"}const Wn=e=>e instanceof D.ChildProcess&&typeof e.then=="function",te=(e,t,n)=>{if(typeof n=="string")return e[t].pipe(R.createWriteStream(n)),e;if(Ae(n))return e[t].pipe(n),e;if(!Wn(n))throw new TypeError("The second argument must be a string, a stream or an Execa child process.");if(!Ae(n.stdin))throw new TypeError("The target child process's stdin must be available.");return e[t].pipe(n.stdin),n},Hn=e=>{e.stdout!==null&&(e.pipeStdout=te.bind(void 0,e,"stdout")),e.stderr!==null&&(e.pipeStderr=te.bind(void 0,e,"stderr")),e.all!==void 0&&(e.pipeAll=te.bind(void 0,e,"all"))},it=async(e,{init:t,convertChunk:n,getSize:r,truncateChunk:i,addChunk:o,getFinalChunk:s,finalize:a},{maxBuffer:c=Number.POSITIVE_INFINITY}={})=>{if(!Vn(e))throw new Error("The first argument must be a Readable, a ReadableStream, or an async iterable.");const u=t();u.length=0;try{for await(const d of e){const m=Xn(d),f=n[m](d,u);ot({convertedChunk:f,state:u,getSize:r,truncateChunk:i,addChunk:o,maxBuffer:c})}return Kn({state:u,convertChunk:n,getSize:r,truncateChunk:i,addChunk:o,getFinalChunk:s,maxBuffer:c}),a(u)}catch(d){throw d.bufferedData=a(u),d}},Kn=({state:e,getSize:t,truncateChunk:n,addChunk:r,getFinalChunk:i,maxBuffer:o})=>{const s=i(e);s!==void 0&&ot({convertedChunk:s,state:e,getSize:t,truncateChunk:n,addChunk:r,maxBuffer:o})},ot=({convertedChunk:e,state:t,getSize:n,truncateChunk:r,addChunk:i,maxBuffer:o})=>{const s=n(e),a=t.length+s;if(a<=o){$e(e,t,i,a);return}const c=r(e,o-t.length);throw c!==void 0&&$e(c,t,i,o),new Yn},$e=(e,t,n,r)=>{t.contents=n(e,t,r),t.length=r},Vn=e=>typeof e=="object"&&e!==null&&typeof e[Symbol.asyncIterator]=="function",Xn=e=>{var r;const t=typeof e;if(t==="string")return"string";if(t!=="object"||e===null)return"others";if((r=globalThis.Buffer)!=null&&r.isBuffer(e))return"buffer";const n=Oe.call(e);return n==="[object ArrayBuffer]"?"arrayBuffer":n==="[object DataView]"?"dataView":Number.isInteger(e.byteLength)&&Number.isInteger(e.byteOffset)&&Oe.call(e.buffer)==="[object ArrayBuffer]"?"typedArray":"others"},{toString:Oe}=Object.prototype;class Yn extends Error{constructor(){super("maxBuffer exceeded");P(this,"name","MaxBufferError")}}const Zn=e=>e,Qn=()=>{},Jn=({contents:e})=>e,st=e=>{throw new Error(`Streams in object mode are not supported: ${String(e)}`)},at=e=>e.length;async function er(e,t){return it(e,ur,t)}const tr=()=>({contents:new ArrayBuffer(0)}),nr=e=>rr.encode(e),rr=new TextEncoder,Ge=e=>new Uint8Array(e),Re=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),ir=(e,t)=>e.slice(0,t),or=(e,{contents:t,length:n},r)=>{const i=ut()?ar(t,r):sr(t,r);return new Uint8Array(i).set(e,n),i},sr=(e,t)=>{if(t<=e.byteLength)return e;const n=new ArrayBuffer(ct(t));return new Uint8Array(n).set(new Uint8Array(e),0),n},ar=(e,t)=>{if(t<=e.maxByteLength)return e.resize(t),e;const n=new ArrayBuffer(t,{maxByteLength:ct(t)});return new Uint8Array(n).set(new Uint8Array(e),0),n},ct=e=>Be**Math.ceil(Math.log(e)/Math.log(Be)),Be=2,cr=({contents:e,length:t})=>ut()?e:e.slice(0,t),ut=()=>"resize"in ArrayBuffer.prototype,ur={init:tr,convertChunk:{string:nr,buffer:Ge,arrayBuffer:Ge,dataView:Re,typedArray:Re,others:st},getSize:at,truncateChunk:ir,addChunk:or,getFinalChunk:Qn,finalize:cr};async function lt(e,t){if(!("Buffer"in globalThis))throw new Error("getStreamAsBuffer() is only supported in Node.js");try{return Ne(await er(e,t))}catch(n){throw n.bufferedData!==void 0&&(n.bufferedData=Ne(n.bufferedData)),n}}const Ne=e=>globalThis.Buffer.from(e);async function lr(e,t){return it(e,hr,t)}const dr=()=>({contents:"",textDecoder:new TextDecoder}),L=(e,{textDecoder:t})=>t.decode(e,{stream:!0}),fr=(e,{contents:t})=>t+e,mr=(e,t)=>e.slice(0,t),pr=({textDecoder:e})=>{const t=e.decode();return t===""?void 0:t},hr={init:dr,convertChunk:{string:Zn,buffer:L,arrayBuffer:L,dataView:L,typedArray:L,others:st},getSize:at,truncateChunk:mr,addChunk:fr,getFinalChunk:pr,finalize:Jn},{PassThrough:gr}=bt;var yr=function(){var e=[],t=new gr({objectMode:!0});return t.setMaxListeners(0),t.add=n,t.isEmpty=r,t.on("unpipe",i),Array.prototype.slice.call(arguments).forEach(n),t;function n(o){return Array.isArray(o)?(o.forEach(n),this):(e.push(o),o.once("end",i.bind(null,o)),o.once("error",t.emit.bind(t,"error")),o.pipe(t,{end:!1}),this)}function r(){return e.length==0}function i(o){e=e.filter(function(s){return s!==o}),!e.length&&t.readable&&t.end()}};const br=Fe(yr),Sr=e=>{if(e!==void 0)throw new TypeError("The `input` and `inputFile` options cannot be both set.")},wr=({input:e,inputFile:t})=>typeof t!="string"?e:(Sr(e),R.createReadStream(t)),Er=(e,t)=>{const n=wr(t);n!==void 0&&(rt(n)?n.pipe(e.stdin):e.stdin.end(n))},xr=(e,{all:t})=>{if(!t||!e.stdout&&!e.stderr)return;const n=br();return e.stdout&&n.add(e.stdout),e.stderr&&n.add(e.stderr),n},ne=async(e,t)=>{if(!(!e||t===void 0)){await yt.setTimeout(0),e.destroy();try{return await t}catch(n){return n.bufferedData}}},re=(e,{encoding:t,buffer:n,maxBuffer:r})=>{if(!(!e||!n))return t==="utf8"||t==="utf-8"?lr(e,{maxBuffer:r}):t===null||t==="buffer"?lt(e,{maxBuffer:r}):Tr(e,r,t)},Tr=async(e,t,n)=>(await lt(e,{maxBuffer:t})).toString(n),Ir=async({stdout:e,stderr:t,all:n},{encoding:r,buffer:i,maxBuffer:o},s)=>{const a=re(e,{encoding:r,buffer:i,maxBuffer:o}),c=re(t,{encoding:r,buffer:i,maxBuffer:o}),u=re(n,{encoding:r,buffer:i,maxBuffer:o*2});try{return await Promise.all([s,a,c,u])}catch(d){return Promise.all([{error:d,signal:d.signal,timedOut:d.timedOut},ne(e,a),ne(t,c),ne(n,u)])}},vr=(async()=>{})().constructor.prototype,Pr=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(vr,e)]),je=(e,t)=>{for(const[n,r]of Pr){const i=typeof t=="function"?(...o)=>Reflect.apply(r.value,t(),o):r.value.bind(t);Reflect.defineProperty(e,n,{...r,value:i})}},Cr=e=>new Promise((t,n)=>{e.on("exit",(r,i)=>{t({exitCode:r,signal:i})}),e.on("error",r=>{n(r)}),e.stdin&&e.stdin.on("error",r=>{n(r)})}),dt=(e,t=[])=>Array.isArray(t)?[e,...t]:[e],Ar=/^[\w.-]+$/,$r=e=>typeof e!="string"||Ar.test(e)?e:`"${e.replaceAll('"','\\"')}"`,Or=(e,t)=>dt(e,t).join(" "),Gr=(e,t)=>dt(e,t).map(n=>$r(n)).join(" "),Rr=St.debuglog("execa").enabled,k=(e,t)=>String(e).padStart(t,"0"),Br=()=>{const e=new Date;return`${k(e.getHours(),2)}:${k(e.getMinutes(),2)}:${k(e.getSeconds(),2)}.${k(e.getMilliseconds(),3)}`},Nr=(e,{verbose:t})=>{t&&E.stderr.write(`[${Br()}] ${e} `)},jr=1e3*1e3*100,Lr=({env:e,extendEnv:t,preferLocal:n,localDir:r,execPath:i})=>{const o=t?{...E.env,...e}:e;return n?sn({env:o,cwd:r,execPath:i}):o},kr=(e,t,n={})=>{const r=nn._parse(e,t,n);return e=r.command,t=r.args,n=r.options,n={maxBuffer:jr,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:n.cwd||E.cwd(),execPath:E.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:Rr,...n},n.env=Lr(n),n.stdio=Cn(n),E.platform==="win32"&&S.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:n,parsed:r}},ie=(e,t,n)=>typeof t!="string"&&!gt.Buffer.isBuffer(t)?n===void 0?void 0:"":e.stripFinalNewline?rn(t):t;function ft(e,t,n){const r=kr(e,t,n),i=Or(e,t),o=Gr(e,t);Nr(o,r.options),zn(r.options);let s;try{s=D.spawn(r.file,r.args,r.options)}catch(p){const g=new D.ChildProcess,b=Promise.reject(Ce({error:p,stdout:"",stderr:"",all:"",command:i,escapedCommand:o,parsed:r,timedOut:!1,isCanceled:!1,killed:!1}));return je(g,b),g}const a=Cr(s),c=Dn(s,r.options,a),u=qn(s,r.options,c),d={isCanceled:!1};s.kill=jn.bind(null,s.kill.bind(s)),s.cancel=Mn.bind(null,s,d);const f=Ye(async()=>{const[{error:p,exitCode:g,signal:b,timedOut:x},B,N,j]=await Ir(s,r.options,u),ye=ie(r.options,B),be=ie(r.options,N),Se=ie(r.options,j);if(p||g!==0||b!==null){const we=Ce({error:p,exitCode:g,signal:b,stdout:ye,stderr:be,all:Se,command:i,escapedCommand:o,parsed:r,timedOut:x,isCanceled:r.options.signal?r.options.signal.aborted:!1,killed:s.killed});if(!r.options.reject)return we;throw we}return{command:i,escapedCommand:o,exitCode:0,stdout:ye,stderr:be,all:Se,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return Er(s,r.options),s.all=xr(s,r.options),Hn(s),je(s,f),s}const _r=typeof __dirname<"u"?__dirname:S.dirname(Le.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:document.currentScript&&document.currentScript.src||new URL("bin.cjs",document.baseURI).href));let _="",F=null;function he(){if(F)return F;const e=oe.platform();if(!/win32|linux|darwin/.test(e))throw new Error(`${e} is not support`);const t=oe.arch();if(!/amd64_v1|arm64|386|x64/.test(t))throw new Error(`${t} is not support`);return F=`${e==="win32"?"windows":e}_${t==="x64"?"amd64_v1":t}`,F}function mt(e=he()){return`go-get-folder-size${e.startsWith("windows")?".exe":""}`}function ge(){if(_)return _;const e=he(),t=mt(e);return _=S.resolve(_r,`../dist/go-get-folder-size_${e}/${t}`),_}async function Fr(e,t=!1,n={}){const{binPath:r=ge(),loose:i=!1}=n,{stdout:o,stderr:s}=await ft(r,{cwd:e,env:{loose:String(i)}});if(s)throw new Error(s);return t?_e.prettyBytes(Number(o)):Number(o)}function Mr(e={}){const{binPath:t=ge(),loose:n=!1}=e;let r=new Map;const i=ft(t,{env:{ipc:String(!0),loose:String(n)}}),o=wt.createInterface({input:i.stdout});function s(){i.killed||(o.close(),i.cancel(),r.clear(),r=null)}let a=!1;function c(d){if(a)return i.stdin.once("drain",()=>{a=!1,i.stdin.write(`${d},`)});a=!i.stdin.write(`${d},`)}o.on("line",d=>{const[m,f]=d.split(","),{pretty:p,resolve:g}=r.get(m);g(p?_e.prettyBytes(Number(f)):Number(f)),r.delete(m)}),i.stderr.on("data",d=>{const[m,...f]=String(d).split(","),{reject:p}=r.get(m);p(new Error(f.toString())),r.delete(m)}),process.once("exit",()=>{s()});async function u(d,m=!1){return new Promise((f,p)=>{r.set(d,{pretty:m,resolve:f,reject:p}),c(d)})}return{close:s,getFolderSizeWithIpc:u}}exports.createGetFolderSizeBinIpc=Mr;exports.detectBinName=mt;exports.detectDefaultBinPath=ge;exports.getFolderSizeBin=Fr;exports.inferVersion=he;