setup-cpp/dist/setup_cpp.js

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