ssh-deploy/dist/index.js

2 lines
11 KiB
JavaScript
Raw Normal View History

2019-10-02 23:52:52 +02:00
#!/usr/bin/env node
(()=>{var e={126:(e,t,r)=>{var s=r(147);var o;if(process.platform==="win32"||global.TESTING_WINDOWS){o=r(1)}else{o=r(728)}e.exports=isexe;isexe.sync=sync;function isexe(e,t,r){if(typeof t==="function"){r=t;t={}}if(!r){if(typeof Promise!=="function"){throw new TypeError("callback not provided")}return new Promise((function(r,s){isexe(e,t||{},(function(e,t){if(e){s(e)}else{r(t)}}))}))}o(e,t||{},(function(e,s){if(e){if(e.code==="EACCES"||t&&t.ignoreErrors){e=null;s=false}}r(e,s)}))}function sync(e,t){try{return o.sync(e,t||{})}catch(e){if(t&&t.ignoreErrors||e.code==="EACCES"){return false}else{throw e}}}},728:(e,t,r)=>{e.exports=isexe;isexe.sync=sync;var s=r(147);function isexe(e,t,r){s.stat(e,(function(e,s){r(e,e?false:checkStat(s,t))}))}function sync(e,t){return checkStat(s.statSync(e),t)}function checkStat(e,t){return e.isFile()&&checkMode(e,t)}function checkMode(e,t){var r=e.mode;var s=e.uid;var o=e.gid;var n=t.uid!==undefined?t.uid:process.getuid&&process.getuid();var c=t.gid!==undefined?t.gid:process.getgid&&process.getgid();var i=parseInt("100",8);var a=parseInt("010",8);var u=parseInt("001",8);var l=i|a;var f=r&u||r&a&&o===c||r&i&&s===n||r&l&&n===0;return f}},1:(e,t,r)=>{e.exports=isexe;isexe.sync=sync;var s=r(147);function checkPathExt(e,t){var r=t.pathExt!==undefined?t.pathExt:process.env.PATHEXT;if(!r){return true}r=r.split(";");if(r.indexOf("")!==-1){return true}for(var s=0;s<r.length;s++){var o=r[s].toLowerCase();if(o&&e.substr(-o.length).toLowerCase()===o){return true}}return false}function checkStat(e,t,r){if(!e.isSymbolicLink()&&!e.isFile()){return false}return checkPathExt(t,r)}function isexe(e,t,r){s.stat(e,(function(s,o){r(s,s?false:checkStat(o,e,t))}))}function sync(e,t){return checkStat(s.statSync(e),e,t)}},898:(e,t,r)=>{"use strict";var s=r(81).spawn;var o=r(837);var escapeSpaces=function(e){if(typeof e==="string"){return e.replace(/\b\s/g,"\\ ")}else{return e}};var escapeSpacesInOptions=function(e){["src","dest","include","exclude","excludeFirst"].forEach((function(t){var r=e[t];if(typeof r==="string"){e[t]=escapeSpaces(r)}else if(Array.isArray(r)===true){e[t]=r.map(escapeSpaces)}}));return e};e.exports=function(e,t){e=e||{};e=o._extend({},e);e=escapeSpacesInOptions(e);var r=e.platform||process.platform;var n=r==="win32";if(typeof e.src==="undefined"){throw new Error("'src' directory is missing from options")}if(typeof e.dest==="undefined"){throw new Error("'dest' directory is missing from options")}var c=e.dest;if(typeof e.host!=="undefined"){c=e.host+":"+e.dest}if(!Array.isArray(e.src)){e.src=[e.src]}var i=[].concat(e.src);i.push(c);var a=(e.args||[]).find((function(e){return e.match(/--chmod=/)}));if(n&&!a){i.push("--chmod=ugo=rwX")}if(typeof e.host!=="undefined"||e.ssh){i.push("--rsh");var u="ssh";if(typeof e.port!=="undefined"){u+=" -p "+e.port}if(typeof e.privateKey!=="undefined"){u+=" -i "+e.privateKey}if(typeof e.sshCmdArgs!=="undefined"){u+=" "+e.sshCmdArgs.join(" ")}i.push(u)}if(e.recursive===true){i.push("--recursive")}if(e.times===true){i.push("--times")}if(e.syncDest===true||e.deleteAll===true){i.push("--delete");i.push("--delete-excluded")}if(e.syncDestIgnoreExcl===true||e.delete===true){i.push("--delete")}if(e.dryRun===true){i.push("--dry-run");i.push("--verbose")}if(typeof e.excludeFirst!=="undefined"&&o.isArray(e.excludeFirst)){e.excludeFirst.forEach((function(e,t){i.push("--exclude="+e)}))}if(typeof e.include!=="undefined"&&o.isArray(e.include)){e.include.forEach((function(e,t){i.push("--include="+e)}))}if(typeof e.exclude!=="undefined"&&o.isArray(e.exclude)){e.exclude.forEach((function(e,t){i.push("--exclude="+e)}))}switch(e.compareMode){case"sizeOnly":i.push("--size-only");break;case"checksum":i.push("--checksum");break}if(typeof e.args!=="undefined"&&o.isArray(e.args)){i=[...new Set([...i,...e.args])]}i=[...new Set(i)];var noop=function(){};var l=e.onStdout||noop;var f=e.onStderr||noop;var d="rsync ";i.forEach((function(e){if(e.substr(0,4)==="ssh "){e='"'+e+'"'}d+=e+" "}));d=d.trim();if(e.noExec){t(null,null,null,d);return}try{var p="";var h="";var y;if(n){y=s("cmd.exe",["/s","/c