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AAV,CAAoC,IAApC,EAAgD;AACpD,MAAI,IAAI,CAAC,UAAL,CAAgB,MAAhB,CAAJ,EAA6B;AAC3B,WAAO,IAAP;AACD;;AACD,SAAO,oBAAoB,IAAI,CAAC,OAAL,CAAa,KAAb,EAAoB,IAApB,CAA3B;AACD,C","sourcesContent":["import { exec, spawn, DebugLogger, ExtraSpawnOptions, log } from \"builder-util\"\nimport { SpawnOptions, execFileSync, ExecFileOptions } from \"child_process\"\nimport { VmManager } from \"./vm\"\n\n/** @internal */\nexport async function parseVmList(debugLogger: DebugLogger) {\n // do not log output if debug - it is huge, logged using debugLogger\n let rawList = await exec(\"prlctl\", [\"list\", \"-i\", \"-s\", \"name\"], undefined, false)\n debugLogger.add(\"parallels.list\", rawList)\n\n rawList = rawList.substring(rawList.indexOf(\"ID:\"))\n\n // let match: Array<string> | null\n const result: Array<ParallelsVm> = []\n for (const info of rawList.split(\"\\n\\n\").map(it => it.trim()).filter(it => it.length > 0)) {\n const vm: any = {}\n for (const line of info.split(\"\\n\")) {\n const meta = /^([^:(\"]+): (.*)$/.exec(line)\n if (meta == null) {\n continue\n }\n\n const key = meta[1].toLowerCase()\n if (key === \"id\" || key === \"os\" || key === \"name\" || key === \"state\" || key === \"name\") {\n vm[key] = meta[2].trim()\n }\n }\n result.push(vm)\n }\n return result\n}\n\n/** @internal */\nexport class ParallelsVmManager extends VmManager {\n private startPromise: Promise<any>\n\n private isExitHookAdded = false\n\n constructor(private readonly vm: ParallelsVm) {\n super()\n\n this.startPromise = this.doStartVm()\n }\n\n get pathSep(): string {\n return \"/\"\n }\n\n private handleExecuteError(error: Error): any {\n if (error.message.includes(\"Unable to open new session in this virtual machine\")) {\n throw new Error(`Please ensure that your are logged in \"${this.vm.name}\" parallels virtual machine. In the future please do not stop VM, but suspend.\\n\\n${error.message}`)\n }\n\n log.warn(\"ensure that 'Share folders' is set to 'All Disks', see https://goo.gl/E6XphP\")\n throw error\n }\n\n async exec(file: string, args: Array<string>, options?: ExecFileOptions): Promise<string> {\n await this.ensureThatVmStarted()\n // it is important to use \"--current-user\" to execute command under logged in user - to access certs.\n return await exec(\"prlctl\", [\"exec\", this.vm.id, \"--current-user\", file.startsWith(\"/\") ? macPathToParallelsWindows(file) : file].concat(args), options)\n .catch(error => this.handleExecuteError(error))\n }\n\n async spawn(file: string, args: Array<string>, options?: SpawnOptions, extraOptions?: ExtraSpawnOptions): Promise<any> {\n await this.ensureThatVmStarted()\n return await spawn(\"prlctl\", [\"exec\", this.vm.id, file].concat(args), options, extraOptions)\n .catch(error => this.handleExecuteError(error))\n }\n\n private async doStartVm() {\n const vmId = this.vm.id\n const state = this.vm.state\n if (state === \"running\") {\n return\n }\n\n if (!this.isExitHookAdded) {\n this.isExitHookAdded = true\n require(\"async-exit-hook\")((callback: (() => void) | null) => {\n const stopArgs = [\"suspend\", vmId]\n if (callback == null) {\n execFileSync(\"prlctl\", stopArgs)\n }\n else {\n exec(\"prlctl\", stopArgs)\n .then(callback)\n .catch(callback)\n }\n })\n }\n await exec(\"prlctl\", [\"start\", vmId])\n }\n\n private ensureThatVmStarted() {\n let startPromise = this.startPromise\n if (startPromise == null) {\n startPromise = this.doStartVm()\n this.startPromise = startPromise\n }\n return startPromise\n }\n\n toVmFile(file: string): string {\n // https://stackoverflow.com/questions/4742992/cannot-access-network-drive-in-powershell-running-as-administrator\n return macPathToParallelsWindows(file)\n }\n}\n\nexport function macPathToParallelsWindows(file: string) {\n if (file.startsWith(\"C:\\\\\")) {\n return file\n }\n return \"\\\\\\\\Mac\\\\Host\\\\\" + file.replace(/\\//g, \"\\\\\")\n}\n\nexport interface ParallelsVm {\n id: string\n name: string\n os: \"win-10\" | \"ubuntu\" | \"elementary\"\n state: \"running\" | \"suspended\" | \"stopped\"\n}"],"sourceRoot":""}