setup-cpp/dist/setup_cpp.js

3 lines
159 KiB
JavaScript
Raw Normal View History

2022-05-13 09:42:49 +08:00
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)}))}))}ze(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 Ye)return{binDir:Ye};const i=t(Ue).sync("brew",{nothrow:!0});return null!==i?(Ye=xe.dirname(i),{binDir:Ye}):(Te.execFileSync('/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"',{stdio:"inherit"}),Ye="/usr/local/bin/",{binDir:Ye})}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=Ue.sync(e.command,{path:r[Qe({env:r})],pathExt:t?xe.delimiter:void 0})}catch(e){}finally{o&&process.chdir(s)}return n&&(n=xe.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 lt&&1===e&&!t.file?o(t.original,"spawn"):null}function a(e,t,r){const s=Ze(e,t,r),i=Te.spawn(s.command,s.args,s.options);return ct.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=nr(t);return await new Promise(((t,i)=>{const o=e=>{e&&s.getBufferedLength()<=cr.MAX_LENGTH&&(e.bufferedData=s.getBufferedValue()),i(e)};(async()=>{try{await ur(e,s),t()}catch(e){o(e)}})(),s.on("data",(()=>{s.getBufferedLength()>r&&o(new dr)}))})),s.getBufferedValue()}function l(){var e;return void 0!==Nr||(Nr=(!!process.env.CI||0===(null===(e=process.getuid)||void 0===e?void 0:e.call(process)))&&null!==t(Ue).sync("sudo",{nothrow:!0})),Nr}function u(e,r,s){return l()?t(Je).commandSync("sudo "+[e,...r].map((e=>`'${e}'`)).join(" "),{shell:!0,cwd:s,stdio:"inherit"}):t(Je).sync(e,r,{stdio:"inherit"})}function d(e){return l()&&"string"==typeof process.env.SUDO_USER?"darwin"===process.platform?xe.join("/Users/",process.env.SUDO_USER,e):xe.join("/home/",process.env.SUDO_USER,e):t(Lr)("~/"+e)}function p(e,r=["-NoProfile","-NoLogo","-NonInteractive"]){return t(Je)((()=>{if(void 0===Mr){const e=t(Ue).sync("pwsh",{nothrow:!0});null!==e&&(Mr=e);const r=t(Ue).sync("powershell",{nothrow:!0});null!==r&&(Mr=r)}if(void 0===Mr)throw Error("Could not find powershell");return Mr})(),[...r,"-c",e],{stdio:"inherit"})}async function h(e,r,s=!1){const i=s?void 0===(o=r)?"":t(Ur)(o):r;var o;try{if(jr.isGitHubCI())try{Me.exportVariable(e,i)}catch(t){Dr.error(t),await m(e,i)}else await m(e,i)}catch(t){Dr.error(t),Me.setFailed(`Failed to export environment variable ${e}=${i}. You should add it manually.`)}}async function f(e){process.env.PATH=`${e}${xe.delimiter}${process.env.PATH}`;try{if(jr.isGitHubCI())try{Me.addPath(e)}catch(t){Dr.error(t),await g(e)}else await g(e)}catch(t){Dr.error(t),Me.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 Me.info(`${e}="${r}" was set in the environment.`);case"linux":case"darwin":return v(),be.appendFileSync(Br,`\nexport ${e}="${r}"\n`),void Me.info(`${e}="${r}" was added to "${Br}`)}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 Me.info(e+" was added to the PATH.");case"linux":case"darwin":return v(),be.appendFileSync(Br,`\nexport PATH=${e}:$PATH\n`),void Me.info(`${e} was added to "${Br}"`);default:return}}function v(){if(qr)return;const e="export SOUR
2021-09-18 04:00:26 +08:00
//# sourceMappingURL=setup_cpp.js.map