mirror of
https://github.com/aminya/setup-cpp
synced 2024-11-30 21:22:30 +08:00
3 lines
79 KiB
JavaScript
3 lines
79 KiB
JavaScript
|
"use strict";function _interopNamespaceDefault(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const r in e)if("default"!==r){const s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:()=>e[r]})}return t.default=e,Object.freeze(t)}function getProxyUrl(e){let t,r,s="https:"===e.protocol;return checkBypass(e)||(r=s?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 s=[e.hostname.toUpperCase()];"number"==typeof t&&s.push(`${s[0]}:${t}`);for(let i of r.split(",").map((e=>e.trim().toUpperCase())).filter((e=>e)))if(s.some((e=>e===i)))return!0;return!1}function downloadTool(e,t,r,s){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 i=_getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS",10),n=_getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS",20),o=new retry_helper_1.RetryHelper(3,i,n);return yield o.execute((()=>__awaiter(this,void 0,void 0,(function*(){return yield downloadToolAttempt(e,t||"",r,s)}))),(e=>!(e instanceof HTTPError&&e.httpStatusCode&&500>e.httpStatusCode&&408!==e.httpStatusCode&&429!==e.httpStatusCode)))}))}function downloadToolAttempt(e,t,r,s){return __awaiter(this,void 0,void 0,(function*(){if(fs.existsSync(t))throw Error(`Destination file path ${t} already exists`);const i=new httpm.HttpClient(userAgent,[],{allowRetries:!1});r&&(core.debug("set auth"),void 0===s&&(s={}),s.authorization=r);const n=yield i.get(e,s);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 s=process.cwd();if(process.chdir(t),r)try{const t=["x",core.isDebug()?"-bb1":"-bb0","-bd","-sccUTF-8",e],s={silent:!0};yield exec_1.exec(`"${r}"`,t,s)}finally{process.chdir(s)}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,"")}'`],i={silent:!0};try{const e=yield io.which("powershell",!0);yield exec_1.exec(`"${e}"`,r,i)}finally{process.chdir(s)}}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 s="";yield exec_1.exec("tar --version",[],{ignoreReturnCode:!0,silent:!0,listeners:{stdout:e=>s+=""+e,stderr:e=>s+=""+e}}),core.debug(s.trim());const i=s.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&&i&&(n.push("--force-local"),o=t.replace(/\\/g,"/"),a=e.replace(/\\/g,"/")),i&&(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 s;assert_1.ok(IS_MAC$1,"extractXar() not supported on current OS"),assert_1.ok(e,'param
|
||
|
//# sourceMappingURL=actions_python-BF80bhWt.js.map
|