setup-cpp/dist/setup_cpp.js

3 lines
178 KiB
JavaScript
Raw Permalink Normal View History

function e(e,t,r,n){Object.defineProperty(e,t,{get:r,set:n,enumerable:!0,configurable:!0})}function t(e){return e&&e.__esModule?e.default:e}function r(e,t,n){if("function"==typeof t&&(n=t,t={}),!n){if("function"!=typeof Promise)throw new TypeError("callback not provided");return new Promise(((n,i)=>{r(e,t||{},((e,t)=>{e?i(e):n(t)}))}))}gt(e,t||{},((e,r)=>{e&&("EACCES"===e.code||t&&t.ignoreErrors)&&(e=null,r=!1),n(e,r)}))}function n(e,r,n){if(!["darwin","linux"].includes(process.platform))return;if("string"==typeof Et)return{binDir:Et};const i=t(ft).sync("brew",{nothrow:!0});return null!==i?(Et=(0,ht.dirname)(i),{binDir:Et}):((0,tt.execFileSync)('/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"',{stdio:"inherit"}),Et="/usr/local/bin/",{binDir:Et})}function i(e,t){const r=e.options.env||process.env,n=process.cwd(),i=null!=e.options.cwd,o=i&&void 0!==process.chdir&&!process.chdir.disabled;if(o)try{process.chdir(e.options.cwd)}catch(e){}let s;try{s=ft.sync(e.command,{path:r[Tt({env:r})],pathExt:t?Ve.delimiter:void 0})}catch(e){}finally{o&&process.chdir(n)}return s&&(s=Ve.resolve(i?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 Mt&&1===e&&!t.file?o(t.original,"spawn"):null}function a(e,t,r){const n=$t(e,t,r),i=tt.spawn(n.command,n.args,n.options);return Ut.hookChildProcess(i,n),i}async function c(e,t){if(!e)throw Error("Expected a stream");t={maxBuffer:1/0,...t};const{maxBuffer:r}=t,n=jr(t);return await new Promise(((t,i)=>{const o=e=>{e&&n.getBufferedLength()<=Ur.MAX_LENGTH&&(e.bufferedData=n.getBufferedValue()),i(e)};(async()=>{try{await Fr(e,n),t()}catch(e){o(e)}})(),n.on("data",(()=>{n.getBufferedLength()>r&&o(new Gr)}))})),n.getBufferedValue()}function l(e,t,r,n){Object.defineProperty(e,t,{get:r,set:n,enumerable:!0,configurable:!0})}function u(){return null!==t(ft).sync("sudo",{nothrow:!0})}function d(){var e;return 0===(null===(e=process.getuid)||void 0===e?void 0:e.call(process))||!!process.env.CI}function p(){return d()&&u()}function h(e){return p()?"sudo "+e:e}function f(e,r=[],n={stdio:"inherit",shell:!0}){return p()?t(Ot).commandSync("sudo "+[e,...r].map((e=>`'${e}'`)).join(" "),n):t(Ot).sync(e,r,n)}function m(e,r=[],n={stdio:"inherit",shell:!0}){return p()?t(Ot).command("sudo "+[e,...r].map((e=>`'${e}'`)).join(" "),n):t(Ot)(e,r,n)}function v(){return"win32"===process.platform?mn():d()}function g(e){return p()&&"string"==typeof process.env.SUDO_USER?"darwin"===process.platform?(0,Ve.join)("/Users/",process.env.SUDO_USER,e):(0,Ve.join)("/home/",process.env.SUDO_USER,e):t(gn)("~/"+e)}function y(e,r=["-NoProfile","-NoLogo","-NonInteractive"],n={stdio:"inherit"}){return t(Ot)((()=>{if(void 0===bn){const e=t(ft).sync("pwsh",{nothrow:!0});null!==e&&(bn=e);const r=t(ft).sync("powershell",{nothrow:!0});null!==r&&(bn=r)}if(void 0===bn)throw Error("Could not find powershell");return bn})(),[...r,"-c",e],n)}async function w(e,r,n=!1){const i=n?t(En)(null!=r?r:""):r;try{if("github-actions"===t(yn)())try{(0,pt.exportVariable)(e,i)}catch(t){(0,xn.error)(t),await b(e,i)}else await b(e,i)}catch(t){(0,xn.error)(t),(0,pt.setFailed)(`Failed to export environment variable ${e}=${i}. You should add it manually.`)}}async function x(e){process.env.PATH=`${e}${Ve.delimiter}${process.env.PATH}`;try{if("github-actions"===t(yn)())try{(0,pt.addPath)(e)}catch(t){(0,xn.error)(t),await E(e)}else await E(e)}catch(t){(0,xn.error)(t),(0,pt.setFailed)(`Failed to add ${e} to the percistent PATH. You should add it manually.`)}}async function b(e,t){const r=null!=t?t:"";switch(process.platform){case"win32":return await y(`[Environment]::SetEnvironmentVariable('${e}', '${r}', "User")`),void(0,pt.info)(`${e}='${r}' was set in the environment.`);case"linux":case"darwin":return S(),(0,Xe.appendFileSync)($n,`\nexport ${e}="${r}"\n`),void(0,pt.info)(`${e}="${r}" was added to "${$n}`)}process.env[e]=r}async function E(e){switch(process.platform){case"wi
2022-08-08 09:30:29 +08:00
//# sourceMappingURL=setup_cpp.js.map