setup-cpp/dist/setup_cpp.js

3 lines
158 KiB
JavaScript
Raw 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,o)=>{r(e,t||{},((e,t)=>{e?o(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 o=t(Ge).sync("brew",{nothrow:!0});return null!==o?(We=be.dirname(o),{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 o(e,t){const r=e.options.env||process.env,s=process.cwd(),o=null!=e.options.cwd,i=o&&void 0!==process.chdir&&!process.chdir.disabled;if(i)try{process.chdir(e.options.cwd)}catch(e){}let n;try{n=Ge.sync(e.command,{path:r[et({env:r})],pathExt:t?be.delimiter:void 0})}catch(e){}finally{i&&process.chdir(s)}return n&&(n=be.resolve(o?e.options.cwd:"",n)),n}function i(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 ut&&1===e&&!t.file?i(t.original,"spawn"):null}function a(e,t,r){const s=Qe(e,t,r),o=Re.spawn(s.command,s.args,s.options);return lt.hookChildProcess(o,s),o}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,o)=>{const i=e=>{e&&s.getBufferedLength()<=lr.MAX_LENGTH&&(e.bufferedData=s.getBufferedValue()),o(e)};(async()=>{try{await dr(e,s),t()}catch(e){i(e)}})(),s.on("data",(()=>{s.getBufferedLength()>r&&i(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){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");t(Ke).sync(Ur,["-c",e],{stdio:"inherit"})}function h(e){return void 0===e?"":"win32"===process.platform?e.replace(/(\s+)/g,"%20"):e.replace(/(\s+)/g,"\\$1")}function f(e,t,r=!0){const s=r?h(t):t;try{Fr.isGitHubCI()?Ue.exportVariable(e,s):g(e,s)}catch(t){try{return jr.error(t),g(e,s)}catch(e){jr.error(e)}Ue.setFailed(`Failed to export environment variable ${e}=${s}. You should add it manually.`)}}function m(e,t=!0){const r=t?h(e):e;process.env.PATH=`${r}${be.delimiter}${process.env.PATH}`;try{Fr.isGitHubCI()?Ue.addPath(r):v(r)}catch(e){try{return jr.error(e),v(r)}catch(e){jr.error(e)}Ue.setFailed(`Failed to add ${r} to the percistent PATH. You should add it manually.`)}}function g(e,t){const r=null!=t?t:"";switch(process.platform){case"win32":return p(`[Environment]::SetEnvironmentVariable("${e}", "${r}", "User")`),void Ue.info(`${e}="${r} was set in the environment."`);case"linux":case"darwin":return y(),Ee.appendFileSync(Gr,`\nexport ${e}="${r}"\n`),void Ue.info(`${e}="${r} was added to "${Gr}"`)}process.env[e]=r}function v(e){switch(process.platform){case"win32":return 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 y(),Ee.appendFileSync(Gr,`\nexport PATH=${e}:$PATH\n`),void Ue.info(`${e} was added to "${Gr}"`);default:return}}function y(){if(Hr)return;const e="export SOURCE_CPPRC=0";if(Ee.exis
2021-09-18 04:00:26 +08:00
//# sourceMappingURL=setup_cpp.js.map