setup-cpp/dist/modern/assets/actions_python-mhNRejTS.mjs

3 lines
77 KiB
JavaScript
Raw Normal View History

2024-09-04 15:51:32 +08:00
function getProxyUrl(e){let t,r,i="https:"===e.protocol;return checkBypass(e)||(r=i?process.env.https_proxy||process.env.HTTPS_PROXY:process.env.http_proxy||process.env.HTTP_PROXY,r&&(t=new URL(r))),t}function checkBypass(e){if(!e.hostname)return!1;let t,r=process.env.no_proxy||process.env.NO_PROXY||"";if(!r)return!1;e.port?t=+e.port:"http:"===e.protocol?t=80:"https:"===e.protocol&&(t=443);let i=[e.hostname.toUpperCase()];"number"==typeof t&&i.push(`${i[0]}:${t}`);for(let s of r.split(",").map((e=>e.trim().toUpperCase())).filter((e=>e)))if(i.some((e=>e===s)))return!0;return!1}function downloadTool(e,t,r,i){return __awaiter(this,void 0,void 0,(function*(){t=t||path.join(_getTempDirectory(),v4_1.default()),yield io.mkdirP(path.dirname(t)),core.debug("Downloading "+e),core.debug("Destination "+t);const s=_getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS",10),n=_getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS",20),o=new retry_helper_1.RetryHelper(3,s,n);return yield o.execute((()=>__awaiter(this,void 0,void 0,(function*(){return yield downloadToolAttempt(e,t||"",r,i)}))),(e=>!(e instanceof HTTPError&&e.httpStatusCode&&500>e.httpStatusCode&&408!==e.httpStatusCode&&429!==e.httpStatusCode)))}))}function downloadToolAttempt(e,t,r,i){return __awaiter(this,void 0,void 0,(function*(){if(fs.existsSync(t))throw Error(`Destination file path ${t} already exists`);const s=new httpm.HttpClient(userAgent,[],{allowRetries:!1});r&&(core.debug("set auth"),void 0===i&&(i={}),i.authorization=r);const n=yield s.get(e,i);if(200!==n.message.statusCode){const t=new HTTPError(n.message.statusCode);throw core.debug(`Failed to download from "${e}". Code(${n.message.statusCode}) Message(${n.message.statusMessage})`),t}const o=util.promisify(stream$1.pipeline),a=_getGlobal("TEST_DOWNLOAD_TOOL_RESPONSE_MESSAGE_FACTORY",(()=>n.message))();let h=!1;try{return yield o(a,fs.createWriteStream(t)),core.debug("download complete"),h=!0,t}finally{if(!h){core.debug("download failed");try{yield io.rmRF(t)}catch(c){core.debug(`Failed to delete '${t}'. ${c.message}`)}}}}))}function extract7z(e,t,r){return __awaiter(this,void 0,void 0,(function*(){assert_1.ok(IS_WINDOWS$1,"extract7z() not supported on current OS"),assert_1.ok(e,'parameter "file" is required'),t=yield _createExtractFolder(t);const i=process.cwd();if(process.chdir(t),r)try{const t=["x",core.isDebug()?"-bb1":"-bb0","-bd","-sccUTF-8",e],i={silent:!0};yield exec_1.exec(`"${r}"`,t,i)}finally{process.chdir(i)}else{const r=["-NoLogo","-Sta","-NoProfile","-NonInteractive","-ExecutionPolicy","Unrestricted","-Command",`& '${path.join(__dirname,"..","scripts","Invoke-7zdec.ps1").replace(/'/g,"''").replace(/"|\n|\r/g,"")}' -Source '${e.replace(/'/g,"''").replace(/"|\n|\r/g,"")}' -Target '${t.replace(/'/g,"''").replace(/"|\n|\r/g,"")}'`],s={silent:!0};try{const e=yield io.which("powershell",!0);yield exec_1.exec(`"${e}"`,r,s)}finally{process.chdir(i)}}return t}))}function extractTar(e,t,r="xz"){return __awaiter(this,void 0,void 0,(function*(){if(!e)throw Error("parameter 'file' is required");t=yield _createExtractFolder(t),core.debug("Checking tar --version");let i="";yield exec_1.exec("tar --version",[],{ignoreReturnCode:!0,silent:!0,listeners:{stdout:e=>i+=""+e,stderr:e=>i+=""+e}}),core.debug(i.trim());const s=i.toUpperCase().includes("GNU TAR");let n;n=r instanceof Array?r:[r],core.isDebug()&&!r.includes("v")&&n.push("-v");let o=t,a=e;return IS_WINDOWS$1&&s&&(n.push("--force-local"),o=t.replace(/\\/g,"/"),a=e.replace(/\\/g,"/")),s&&(n.push("--warning=no-unknown-keyword"),n.push("--overwrite")),n.push("-C",o,"-f",a),yield exec_1.exec("tar",n),t}))}function extractXar(e,t,r=[]){return __awaiter(this,void 0,void 0,(function*(){let i;assert_1.ok(IS_MAC$1,"extractXar() not supported on current OS"),assert_1.ok(e,'parameter "file" is required'),t=yield _createExtractFolder(t),i=r instanceof Array?r:[r],i.push("-x","-C",t,"-f",e),core.isDebug()&&i.push("-v");const s=yield io.which("xar",!0);return yield exec_1.exec(`"${s}"`,_unique(i)),t}))}function extractZip(e,t){return __awaiter(this,void 0,void 0,(function*(){if(!
//# sourceMappingURL=actions_python-mhNRejTS.mjs.map