setup-cpp/dist/setup_cpp.js

3 lines
152 KiB
JavaScript
Raw Permalink Normal View History

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)}))}))}Me(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 He)return{binDir:He};const i=t(Le).sync("brew",{nothrow:!0});return null!==i?(He=me.dirname(i),{binDir:He}):(Oe.execFileSync('/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"',{stdio:"inherit"}),He="/usr/local/bin/",{binDir:He})}function i(e,t){const r=e.options.env||process.env,s=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 n;try{n=Le.sync(e.command,{path:r[We({env:r})],pathExt:t?me.delimiter:void 0})}catch(e){}finally{o&&process.chdir(s)}return n&&(n=me.resolve(i?e.options.cwd:"",n)),n}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 n(e,t){return it&&1===e&&!t.file?o(t.original,"spawn"):null}function a(e,t,r){const s=Xe(e,t,r),i=Oe.spawn(s.command,s.args,s.options);return st.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=tr(t);return await new Promise(((t,i)=>{const o=e=>{e&&s.getBufferedLength()<=sr.MAX_LENGTH&&(e.bufferedData=s.getBufferedValue()),i(e)};(async()=>{try{await or(e,s),t()}catch(e){o(e)}})(),s.on("data",(()=>{s.getBufferedLength()>r&&o(new nr)}))})),s.getBufferedValue()}function l(){var e;return void 0!==Ir||(Ir=(!!process.env.CI||0===(null===(e=process.getuid)||void 0===e?void 0:e.call(process)))&&null!==t(Le).sync("sudo",{nothrow:!0})),Ir}function u(e,r,s){return l()?t(Be).command("sudo "+[e,...r].map((e=>`'${e}'`)).join(" "),{shell:!0,cwd:s,stdio:"inherit"}):t(Be)(e,r,{stdio:"inherit"})}function p(e){return l()&&"string"==typeof process.env.SUDO_USER?"darwin"===process.platform?me.join("/Users/",process.env.SUDO_USER,e):me.join("/home/",process.env.SUDO_USER,e):t(Ar)("~/"+e)}function d(e){if(void 0===kr){const e=t(Le).sync("pwsh",{nothrow:!0});null!==e&&(kr=e);const r=t(Le).sync("powershell",{nothrow:!0});null!==r&&(kr=r)}if(void 0===kr)throw Error("Could not find powershell");t(Be).sync(kr,["-c",e],{stdio:"inherit"})}function h(e,t){try{Pr.isGitHubCI()?ke.exportVariable(e,t):m(e,t)}catch(r){try{return Rr.error(r),m(e,t)}catch(e){Rr.error(e)}Rr.error(`Failed to export environment variable ${e}=${t}. You should add it manually.`)}}function f(e){process.env.PATH=`${e}${me.delimiter}${process.env.PATH}`;try{Pr.isGitHubCI()?ke.addPath(e):g(e)}catch(t){try{return Rr.error(t),g(e)}catch(e){Rr.error(e)}Rr.error(`Failed to add ${e} to the percistent PATH. You should add it manually.`)}}function m(e,t){const r=null!=t?t:"";switch(process.platform){case"win32":return d(`[Environment]::SetEnvironmentVariable("${e}", "${r}", "User")`),void ke.info(`${e}="${r} was set in the environment."`);case"linux":case"darwin":return v(),ge.appendFileSync(Lr,`\nexport ${e}="${r}"\n`),void ke.info(`${e}="${r} was added to "${Lr}"`)}process.env[e]=r}function g(e){switch(process.platform){case"win32":return d(`$USER_PATH=([Environment]::GetEnvironmentVariable("PATH", "User")); [Environment]::SetEnvironmentVariable("PATH", "${e};$USER_PATH", "User")`),void ke.info(e+" was added to the PATH.");case"linux":case"darwin":return v(),ge.appendFileSync(Lr,`\nexport PATH=${e}:$PATH\n`),void ke.info(`${e} was added to "${Lr}"`);default:return}}function v(){if(Dr)return;const e="export SOURCE_CPPRC=0";if(ge.existsSync(Lr)&&ge.readFileSync(Lr,"utf8").includes(e))return;ge.appendFileSync(Lr,`\n${e}\n`),ke.info(`Added ${e} to ${Lr}`);const t=`\n# source .cpprc if SOURCE_CPPRC is not set
2021-09-18 04:00:26 +08:00
//# sourceMappingURL=setup_cpp.js.map