toolchain/dist/index.js

1 line
12 KiB
JavaScript
Raw Normal View History

2019-09-12 23:10:51 +08:00
module.exports=function(e,t){"use strict";var s={};function __webpack_require__(t){if(s[t]){return s[t].exports}var i=s[t]={i:t,l:false,exports:{}};e[t].call(i.exports,i,i.exports,__webpack_require__);i.l=true;return i.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(131)}return startup()}({9:function(e,t,s){"use strict";var i=this&&this.__awaiter||function(e,t,s,i){function adopt(e){return e instanceof s?e:new s(function(t){t(e)})}return new(s||(s=Promise))(function(s,n){function fulfilled(e){try{step(i.next(e))}catch(e){n(e)}}function rejected(e){try{step(i["throw"](e))}catch(e){n(e)}}function step(e){e.done?s(e.value):adopt(e.value).then(fulfilled,rejected)}step((i=i.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});const n=s(87);const r=s(614);const o=s(129);const u=process.platform==="win32";class ToolRunner extends r.EventEmitter{constructor(e,t,s){super();if(!e){throw new Error("Parameter 'toolPath' cannot be null or empty.")}this.toolPath=e;this.args=t||[];this.options=s||{}}_debug(e){if(this.options.listeners&&this.options.listeners.debug){this.options.listeners.debug(e)}}_getCommandString(e,t){const s=this._getSpawnFileName();const i=this._getSpawnArgs(e);let n=t?"":"[command]";if(u){if(this._isCmdFile()){n+=s;for(const e of i){n+=` ${e}`}}else if(e.windowsVerbatimArguments){n+=`"${s}"`;for(const e of i){n+=` ${e}`}}else{n+=this._windowsQuoteCmdArg(s);for(const e of i){n+=` ${this._windowsQuoteCmdArg(e)}`}}}else{n+=s;for(const e of i){n+=` ${e}`}}return n}_processLineBuffer(e,t,s){try{let i=t+e.toString();let r=i.indexOf(n.EOL);while(r>-1){const e=i.substring(0,r);s(e);i=i.substring(r+n.EOL.length);r=i.indexOf(n.EOL)}t=i}catch(e){this._debug(`error processing line. Failed with error ${e}`)}}_getSpawnFileName(){if(u){if(this._isCmdFile()){return process.env["COMSPEC"]||"cmd.exe"}}return this.toolPath}_getSpawnArgs(e){if(u){if(this._isCmdFile()){let t=`/D /S /C "${this._windowsQuoteCmdArg(this.toolPath)}`;for(const s of this.args){t+=" ";t+=e.windowsVerbatimArguments?s:this._windowsQuoteCmdArg(s)}t+='"';return[t]}}return this.args}_endsWith(e,t){return e.endsWith(t)}_isCmdFile(){const e=this.toolPath.toUpperCase();return this._endsWith(e,".CMD")||this._endsWith(e,".BAT")}_windowsQuoteCmdArg(e){if(!this._isCmdFile()){return this._uvQuoteCmdArg(e)}if(!e){return'""'}const t=[" ","\t","&","(",")","[","]","{","}","^","=",";","!","'","+",",","`","~","|","<",">",'"'];let s=false;for(const i of e){if(t.some(e=>e===i)){s=true;break}}if(!s){return e}let i='"';let n=true;for(let t=e.length;t>0;t--){i+=e[t-1];if(n&&e[t-1]==="\\"){i+="\\"}else if(e[t-1]==='"'){n=true;i+='"'}else{n=false}}i+='"';return i.split("").reverse().join("")}_uvQuoteCmdArg(e){if(!e){return'""'}if(!e.includes(" ")&&!e.includes("\t")&&!e.includes('"')){return e}if(!e.includes('"')&&!e.includes("\\")){return`"${e}"`}let t='"';let s=true;for(let i=e.length;i>0;i--){t+=e[i-1];if(s&&e[i-1]==="\\"){t+="\\"}else if(e[i-1]==='"'){s=true;t+="\\"}else{s=false}}t+='"';return t.split("").reverse().join("")}_cloneExecOptions(e){e=e||{};const t={cwd:e.cwd||process.cwd(),env:e.env||process.env,silent:e.silent||false,windowsVerbatimArguments:e.windowsVerbatimArguments||false,failOnStdErr:e.failOnStdErr||false,ignoreReturnCode:e.ignoreReturnCode||false,delay:e.delay||1e4};t.outStream=e.outStream||process.stdout;t.errStream=e.errStream||process.stderr;return t}_getSpawnOptions(e,t){e=e||{};const s={};s.cwd=e.cwd;s.env=e.env;s["windowsVerbatimArguments"]=e.windowsVerbatimArguments||this._isCmdFile();if(e.windowsVerbatimArguments){s.argv0=`"${t}"`}return s}exec(){return i(this,void 0,void 0,function*(){return new Promise((e,t)=>{this._debug(`exec tool: ${this.toolPath}`);this._debug("arguments:");for(const e of this.args){this._debug(` ${e}`)}const s=this._cloneExecOptions(this.options);if(!s.silent&&s.outStream){s.outStream.write(this._getCommandString(s)+n.EOL)}const i=new ExecState(s,this.toolPath);i.on("debug",e=>{this._debug(e)});const r=this._getSpawnFileName();const u=o.spawn(r,this._getSpawnAr