Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "${o}" ${this.flags.join(" ")}`),this.chromeProcess=this.spawn(o,this.flags,{detached:process.platform!=="win32",stdio:["ignore",this.outFile,this.errFile],env:this.envVars}),this.chromeProcess.pid&&this.fs.writeFileSync(this.pidFile,this.chromeProcess.pid.toString()),Jt.verbose("ChromeLauncher",`Chrome running with pid ${this.chromeProcess.pid} on port ${this.port}.`),this.chromeProcess.pid))();return await this.waitUntilReady(),n}cleanup(o){o&&(o.removeAllListeners(),o.end(),o.destroy(),o.unref())}isDebuggerReady(){return new Promise((o,s)=>{let n=tR.createConnection(this.port,"127.0.0.1");n.once("error",r=>{this.cleanup(n),s(r)}),n.once("connect",()=>{this.cleanup(n),o()})})}waitUntilReady(){let o=this;return new Promise((s,n)=>{let r=0,p="Waiting for browser.",l=()=>{r===0&&Jt.log("ChromeLauncher",p),r++,p+="..",Jt.log("ChromeLauncher",p),o.isDebuggerReady().then(()=>{Jt.log("ChromeLauncher",p+`${Jt.greenify(Jt.tick)}`),s()}).catch(m=>{if(r>o.maxConnectionRetries){Jt.error("ChromeLauncher",m.message);let g=this.fs.readFileSync(`${this.userDataDir}/chrome-err.log`,{encoding:"utf-8"});return Jt.error("ChromeLauncher",`Logging contents of ${this.userDataDir}/chrome-err.log`),Jt.error("ChromeLauncher",g),n(m)}Ko.delay(o.connectionPollInterval).then(l)})};l()})}kill(){if(this.chromeProcess){this.chromeProcess.on("close",()=>{delete this.chromeProcess,this.destroyTmp()}),Jt.log("ChromeLauncher",`Killing Chrome instance ${this.chromeProcess.pid}`);try{if(iR){let o=ib.spawnSync(`taskkill /pid ${this.chromeProcess.pid} /T /F`,{shell:!0,encoding:"utf-8"}),{stderr:s}=o;s&&Jt.error("ChromeLauncher","taskkill stderr",s)}else this.chromeProcess.pid&&process.kill(-this.chromeProcess.pid,"SIGKILL")}catch(o){let s=`Chrome could not be killed ${o.message}`;Jt.warn("ChromeLauncher",s)}this.destroyTmp()}}destroyTmp(){if(this.userDataDir===void 0||this.opts.userDataDir!==void 0)return;this.outFile&&(this.fs.closeSync(this.outFile),delete this.outFile),this.errFile&&(this.fs.closeSync(this.errFile),delete this.errFile),(this.fs.rmSync||this.fs.rmdirSync)(this.userDataDir,{recursive:!0,force:!0,maxRetries:10})}};Ls.Launcher=ci;Ls.default=ci});var db=X(ga=>{"use strict";var dR=ga&&ga.__createBinding||(Object.create?function(e,o,s,n){n===void 0&&(n=s),Object.defineProperty(e,n,{enumerable:!0,get:function(){return o[s]}})}:function(e,o,s,n){n===void 0&&(n=s),e[n]=o[s]}),NR=ga&&ga.__exportStar||function(e,o){for(var s in e)s!=="default"&&!Object.prototype.hasOwnProperty.call(o,s)&&dR(o,e,s)};Object.defineProperty(ga,"__esModule",{value:!0});NR(lb(),ga)});var yb=X((LX,fb)=>{"use strict";var cb=require("util"),cR=require("path"),ub=require("child_process"),mb=require("process").pid,Um=require("os"),Km=1e3*1e3*10,Nb=cb.promisify(ub.exec),uR=cb.promisify(ub.execFile);async function mR(e={}){let o=e.processName?`-Query "select Name,IDProcess,PercentProcessorTime from Win32_PerfFormattedData_PerfProc_Process where Name like '${e.processName.split(".").shift()}%' "`:'"Win32_PerfFormattedData_PerfProc_Process"',s=e.processName?`-Query "select * from Win32_Process where Name like '${e.processName.split(".").shift()}%' "`:'"Win32_Process"',{includeSelf:n}=e;try{let{error:r,stdout:p,stderr:l}=await Nb(`Get-WmiObject ${o}`,{shell:"powershell",maxBuffer:Km});if(p==="")return[];let m=p.trim().split(Um.EOL).reduce((g,f)=>(f.match(/^$/)?g.unshift({}):g[0][f.split(":")[0]?.trim().toLocaleLowerCase()]=f.split(":")[1]?.trim(),g),[{}]);return{stdout:p}=await Nb(`Get-WmiObject ${s}`,{shell:"powershell",maxBuffer:Km}),p=p.trim().split(Um.EOL).reduce((g,f)=>(f.match(/^$/)?g.unshift({}):g[0][f.split(":")[0]?.trim().toLocaleLowerCase()]=f.split(":")[1]?.trim(),g),[{}]).map(g=>{let f=Number.parseInt(g.processid,10);if(e.redact){let h=e.redact instanceof Array&&e.redact.length?e.redact[0]:e.redact,k=e.redact instanceof Array&&e.redact.length>1?e.redact[1]:"***redacted***";g=Object.entries(g).reduce((B,w)=>({[w[0]]:typeof w[1]=="string"?w[1].replace(h,k):w[1],...B}),{})}return Object.assign(g,{pid:f,cmd:g.commandline,ppid:Number.parseInt(g.parentprocessid,10),cpu:m.find(h=>Number.parseInt(h.idprocess)===f)?.percentprocessortime/Um.cpus().length,memory:Number.parseFloat(g.workingsetsize),platform:process.platform})}),n||(p=p.filter(g=>g.pid!==mb)),p}catch(r){console.dir(r)}}async function fR(e={}){let o={},s=(e.all===!1?"":"a")+"wwxo",{includeSelf:n}=e;return await Promise.all(["comm","args","ppid","uid","%cpu","%mem"].map(async l=>{let{stdout:m}=await uR("ps",[s,`pid,${l}`],{maxBuffer:Km});for(let g of m.trim().split(`
- SyntaxError: Unexpected token '.'
- at wrapSafe (internal/modules/cjs/loader.js:915:16)
- at Module._compile (internal/modules/cjs/loader.js:963:27)
- at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
- at Module.load (internal/modules/cjs/loader.js:863:32)
- at Function.Module._load (internal/modules/cjs/loader.js:708:14)
- at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
- at internal/main/run_main_module.js:17:47
Advertisement
Add Comment
Please, Sign In to add comment