"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var child_process_1=require("child_process"),path_1=require("path"),operators_1=require("rxjs/operators"),utils_1=require("../../lib/utils");function default_1(e){var t=e.options||{},r=utils_1.getEnvironment(),o=r.workspaceRoot,s=r.frontendRoot,e=r.frontendType,r=r.frontendName;if(!o)throw Error("请在 NgCortex 工程目录中操作！");if(!s)throw new Error("请在前端项目目录中操作！");if("micro-frontend"===e){var r={getPascalCase:utils_1.getPascalCase,getSeparatorCase:utils_1.getSeparatorCase,name:r.replace(/-micro-frontend$/,""),microFrontendName:r},i=path_1.join(s,"__dev-frontend__");process.chdir(__dirname),utils_1.src("./**/*",{base:"./files"}).pipe(utils_1.ejs(r)).pipe(utils_1.dest(i)).subscribe(function(){var e="win32"===process.platform?"ng.cmd":"ng",r=["serve"];t.host&&r.push("--host="+t.host),t.port&&r.push("--port="+t.port),t.open&&r.push("--open="+t.open);var o=child_process_1.spawn(e,r,{cwd:i,stdio:["ignore","inherit","inherit"]});o.on("error",function(){return utils_1.src([i,i+"/**/*"],{read:!1}).pipe(operators_1.delay(100)).pipe(utils_1.clean()).subscribe()}),o.on("close",function(){return utils_1.src([i,i+"/**/*"],{read:!1}).pipe(operators_1.delay(100)).pipe(utils_1.clean()).subscribe()}),process.on("SIGINT",function(){return o.kill("SIGINT")}),process.on("SIGHUP",function(){})})}else{var n="ng serve";t.host&&(n+=" --host="+t.host),t.port&&(n+=" --port="+t.port),t.open&&(n+=" --open="+t.open);try{child_process_1.execSync(n,{cwd:s,stdio:"inherit"})}catch(e){process.exit()}}}exports.default=default_1;
