setup-cpp/dist/setup_cpp.mjs

3 lines
173 KiB
JavaScript
Raw Normal View History

function e(e,t,r,i){Object.defineProperty(e,t,{get:r,set:i,enumerable:!0,configurable:!0})}function t(e){return e&&e.__esModule?e.default:e}function r(e,t,i){if("function"==typeof t&&(i=t,t={}),!i){if("function"!=typeof Promise)throw new TypeError("callback not provided");return new Promise(((i,n)=>{r(e,t||{},((e,t)=>{e?n(e):i(t)}))}))}mt(e,t||{},((e,r)=>{e&&("EACCES"===e.code||t&&t.ignoreErrors)&&(e=null,r=!1),i(e,r)}))}function i(e,r,i){if(!["darwin","linux"].includes(process.platform))return;if("string"==typeof xt)return{binDir:xt};const n=t(pt).sync("brew",{nothrow:!0});return null!==n?(xt=$gCrli$dirname(n),{binDir:xt}):($gCrli$execFileSync('/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"',{stdio:"inherit"}),xt="/usr/local/bin/",{binDir:xt})}function n(e,t){const r=e.options.env||process.env,i=process.cwd(),n=null!=e.options.cwd,o=n&&void 0!==process.chdir&&!process.chdir.disabled;if(o)try{process.chdir(e.options.cwd)}catch(e){}let s;try{s=pt.sync(e.command,{path:r[St({env:r})],pathExt:t?$gCrli$delimiter:void 0})}catch(e){}finally{o&&process.chdir(i)}return s&&(s=$gCrli$resolve(n?e.options.cwd:"",s)),s}function o(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 s(e,t){return jt&&1===e&&!t.file?o(t.original,"spawn"):null}function a(e,t,r){const i=Ct(e,t,r),n=$gCrli$spawn(i.command,i.args,i.options);return Dt.hookChildProcess(n,i),n}async function l(e,t){if(!e)throw Error("Expected a stream");t={maxBuffer:1/0,...t};const{maxBuffer:r}=t,i=Nr(t);return await new Promise(((t,n)=>{const o=e=>{e&&i.getBufferedLength()<=Dr.MAX_LENGTH&&(e.bufferedData=i.getBufferedValue()),n(e)};(async()=>{try{await Ur(e,i),t()}catch(e){o(e)}})(),i.on("data",(()=>{i.getBufferedLength()>r&&o(new Fr)}))})),i.getBufferedValue()}function c(){return(!!process.env.CI||0===(null===(e=process.getuid)||void 0===e?void 0:e.call(process)))&&null!==t(pt).sync("sudo",{nothrow:!0});var e}function u(e,r=[],i={stdio:"inherit",shell:!0}){return c()?t(Et).commandSync("sudo "+[e,...r].map((e=>`'${e}'`)).join(" "),i):t(Et).sync(e,r,i)}function d(e){return c()&&"string"==typeof process.env.SUDO_USER?"darwin"===process.platform?$gCrli$join("/Users/",process.env.SUDO_USER,e):$gCrli$join("/home/",process.env.SUDO_USER,e):t(di)("~/"+e)}function p(e,r=["-NoProfile","-NoLogo","-NonInteractive"],i={stdio:"inherit"}){return t(Et)((()=>{if(void 0===mi){const e=t(pt).sync("pwsh",{nothrow:!0});null!==e&&(mi=e);const r=t(pt).sync("powershell",{nothrow:!0});null!==r&&(mi=r)}if(void 0===mi)throw Error("Could not find powershell");return mi})(),[...r,"-c",e],i)}async function h(e,r,i=!1){const n=i?t(gi)(null!=r?r:""):r;try{if("github-actions"===t(pi)())try{(0,dt.exportVariable)(e,n)}catch(t){(0,fi.error)(t),await m(e,n)}else await m(e,n)}catch(t){(0,fi.error)(t),(0,dt.setFailed)(`Failed to export environment variable ${e}=${n}. You should add it manually.`)}}async function f(e){process.env.PATH=`${e}${$gCrli$delimiter}${process.env.PATH}`;try{if("github-actions"===t(pi)())try{(0,dt.addPath)(e)}catch(t){(0,fi.error)(t),await g(e)}else await g(e)}catch(t){(0,fi.error)(t),(0,dt.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(0,dt.info)(`${e}='${r}' was set in the environment.`);case"linux":case"darwin":return v(),$gCrli$appendFileSync(xi,`\nexport ${e}="${r}"\n`),void(0,dt.info)(`${e}="${r}" was added to "${xi}`)}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(0,dt.info)(`"${e}" was added to the PATH.`);case"linux":case"darwin":return v(),$gCrli$appendFileSync(xi,`\nexport PATH="${e}:$PATH"\n`),void(0,dt.info)(`"${e}" was added to "${xi}
2022-08-08 09:30:29 +08:00
//# sourceMappingURL=setup_cpp.mjs.map