setup-cpp/dist/setup_cpp.js

3 lines
160 KiB
JavaScript
Raw Normal View History

2022-05-21 08:07:25 +08:00
function e(e,t,r,s){Object.defineProperty(e,t,{get:r,set:s,enumerable:!0,configurable:!0})}function t(e){return e&&e.__esModule?e.default:e}function r(e,t,s){if("function"==typeof t&&(s=t,t={}),!s){if("function"!=typeof Promise)throw new TypeError("callback not provided");return new Promise(((s,i)=>{r(e,t||{},((e,t)=>{e?i(e):s(t)}))}))}Be(e,t||{},((e,r)=>{e&&("EACCES"===e.code||t&&t.ignoreErrors)&&(e=null,r=!1),s(e,r)}))}function s(e,r,s){if(!["darwin","linux"].includes(process.platform))return;if("string"==typeof We)return{binDir:We};const i=t(Ge).sync("brew",{nothrow:!0});return null!==i?(We=be.dirname(i),{binDir:We}):(Re.execFileSync('/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"',{stdio:"inherit"}),We="/usr/local/bin/",{binDir:We})}function i(e,t){const r=e.options.env||process.env,s=process.cwd(),i=null!=e.options.cwd,n=i&&void 0!==process.chdir&&!process.chdir.disabled;if(n)try{process.chdir(e.options.cwd)}catch(e){}let o;try{o=Ge.sync(e.command,{path:r[et({env:r})],pathExt:t?be.delimiter:void 0})}catch(e){}finally{n&&process.chdir(s)}return o&&(o=be.resolve(i?e.options.cwd:"",o)),o}function n(e,t){return Object.assign(Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function o(e,t){return ut&&1===e&&!t.file?n(t.original,"spawn"):null}function a(e,t,r){const s=Qe(e,t,r),i=Re.spawn(s.command,s.args,s.options);return lt.hookChildProcess(i,s),i}async function c(e,t){if(!e)throw Error("Expected a stream");t={maxBuffer:1/0,...t};const{maxBuffer:r}=t,s=ar(t);return await new Promise(((t,i)=>{const n=e=>{e&&s.getBufferedLength()<=lr.MAX_LENGTH&&(e.bufferedData=s.getBufferedValue()),i(e)};(async()=>{try{await dr(e,s),t()}catch(e){n(e)}})(),s.on("data",(()=>{s.getBufferedLength()>r&&n(new pr)}))})),s.getBufferedValue()}function l(){var e;return void 0!==Lr||(Lr=(!!process.env.CI||0===(null===(e=process.getuid)||void 0===e?void 0:e.call(process)))&&null!==t(Ge).sync("sudo",{nothrow:!0})),Lr}function u(e,r,s){return l()?t(Ke).commandSync("sudo "+[e,...r].map((e=>`'${e}'`)).join(" "),{shell:!0,cwd:s,stdio:"inherit"}):t(Ke).sync(e,r,{stdio:"inherit"})}function d(e){return l()&&"string"==typeof process.env.SUDO_USER?"darwin"===process.platform?be.join("/Users/",process.env.SUDO_USER,e):be.join("/home/",process.env.SUDO_USER,e):t(Dr)("~/"+e)}function p(e,r=["-NoProfile","-NoLogo","-NonInteractive"]){return t(Ke)((()=>{if(void 0===Ur){const e=t(Ge).sync("pwsh",{nothrow:!0});null!==e&&(Ur=e);const r=t(Ge).sync("powershell",{nothrow:!0});null!==r&&(Ur=r)}if(void 0===Ur)throw Error("Could not find powershell");return Ur})(),[...r,"-c",e],{stdio:"inherit"})}async function h(e,r,s=!1){const i=s?void 0===(n=r)?"":t(Gr)(n):r;var n;try{if(Fr.isGitHubCI())try{Ue.exportVariable(e,i)}catch(t){jr.error(t),await m(e,i)}else await m(e,i)}catch(t){jr.error(t),Ue.setFailed(`Failed to export environment variable ${e}=${i}. You should add it manually.`)}}async function f(e){process.env.PATH=`${e}${be.delimiter}${process.env.PATH}`;try{if(Fr.isGitHubCI())try{Ue.addPath(e)}catch(t){jr.error(t),await g(e)}else await g(e)}catch(t){jr.error(t),Ue.setFailed(`Failed to add ${e} to the percistent PATH. You should add it manually.`)}}async function m(e,t){const r=null!=t?t:"";switch(process.platform){case"win32":return await p(`[Environment]::SetEnvironmentVariable('${e}', '${r}', "User")`),void Ue.info(`${e}='${r}' was set in the environment.`);case"linux":case"darwin":return v(),Ee.appendFileSync(qr,`\nexport ${e}="${r}"\n`),void Ue.info(`${e}="${r}" was added to "${qr}`)}process.env[e]=r}async function g(e){switch(process.platform){case"win32":return await p(`$USER_PATH=([Environment]::GetEnvironmentVariable("PATH", "User")); [Environment]::SetEnvironmentVariable("PATH", "${e};$USER_PATH", "User")`),void Ue.info(e+" was added to the PATH.");case"linux":case"darwin":return v(),Ee.appendFileSync(qr,`\nexport PATH=${e}:$PATH\n`),void Ue.info(`${e} was added to "${qr}"`);default:return}}function v(){if(Vr)return;const e="export SOUR
2021-09-18 04:00:26 +08:00
//# sourceMappingURL=setup_cpp.js.map