(()=>{"use strict";var __webpack_modules__={57147:module=>{module.exports=require("fs")},77282:module=>{module.exports=require("process")},14521:module=>{module.exports=require("readline")}};var __webpack_module_cache__={};function __webpack_require__(moduleId){var cachedModule=__webpack_module_cache__[moduleId];if(cachedModule!==undefined){return cachedModule.exports}var module=__webpack_module_cache__[moduleId]={exports:{}};__webpack_modules__[moduleId](module,module.exports,__webpack_require__);return module.exports}var __webpack_exports__={};(()=>{var exports=__webpack_exports__;var __webpack_unused_export__;__webpack_unused_export__={value:true};const readline=__webpack_require__(14521);const process=__webpack_require__(77282);const fs=__webpack_require__(57147);function splitArg(v){const key=v.substr(0,v.indexOf("="));return[key?key:v,v]}const varRe=/^(\s*)(MEMORY_LIMIT|CUSTOM_NODE_ARGS|CUSTOM_MEMORY_LIMIT)=([^$].*|)$/;function extractVar(line,to){const m=line.match(varRe);if(m){to[m[2]]=m[3]}}async function perform(){const oldNodeArgs={};for await(const line of readline.createInterface({input:process.stdin})){const v=splitArg(line);oldNodeArgs[v[0]]=v[1]}const newVars={MEMORY_LIMIT:3084,CUSTOM_NODE_ARGS:"",CUSTOM_MEMORY_LIMIT:""};for await(const line of readline.createInterface({input:fs.createReadStream(process.argv[2])})){extractVar(line,newVars)}const oldVars={};for await(const line of readline.createInterface({input:fs.createReadStream(process.argv[3])})){extractVar(line,oldVars)}if(oldVars["CUSTOM_NODE_ARGS"]===undefined){const oldMemArg=oldNodeArgs["--max_old_space_size"];if(oldMemArg){const oldMemSizeStr=oldMemArg.substr(oldMemArg.indexOf("=")+1);if(Number(oldMemSizeStr)>Number(newVars["MEMORY_LIMIT"])){newVars["CUSTOM_MEMORY_LIMIT"]=oldMemSizeStr}}delete oldNodeArgs["--max_old_space_size"];delete oldNodeArgs["--no-deprecation"];const extraArgs=Object.values(oldNodeArgs);if(extraArgs.length>0){newVars["CUSTOM_NODE_ARGS"]=`"${extraArgs.join(" ")}"`}}else{newVars["CUSTOM_NODE_ARGS"]=oldVars["CUSTOM_NODE_ARGS"]||"";newVars["CUSTOM_MEMORY_LIMIT"]=oldVars["CUSTOM_MEMORY_LIMIT"]||""}for await(const line of readline.createInterface({input:fs.createReadStream(process.argv[2])})){const m=line.match(varRe);if(m){console.log(m[1]+m[2]+"="+newVars[m[2]])}else{console.log(line)}}}perform().then((()=>{process.exit(0)})).catch((err=>{console.error(err);process.exit(1)}))})()})();
//# sourceMappingURL=migrateSrvctrl.js.map