UNPKG

st-bundle

Version:

CLI for watching and bundling SpringType projects.

34 lines (33 loc) 1.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const child_process_1 = require("child_process"); const Bundle_1 = require("../bundle/Bundle"); class ServerLauncher { constructor(ctx, response) { this.ctx = ctx; this.response = response; } kill() { if (this.node) this.node.kill(); } handleEntry(props) { this.kill(); let nodeArgs = []; let scriptArgs = []; if (props) { if (props.nodeArgs) nodeArgs = props.nodeArgs; if (props.scriptArgs) scriptArgs = props.scriptArgs; } const serverEntry = this.response.find(item => item.bundle.props.type == Bundle_1.BundleType.SERVER_ENTRY); if (!serverEntry) { return this.ctx.fatal('Server entry was not found', ['Make sure your dist contains server entry']); } this.node = child_process_1.spawn('node', [...nodeArgs, serverEntry.stat.absPath, ...scriptArgs], { stdio: 'inherit', }); } } exports.ServerLauncher = ServerLauncher;