Created
June 9, 2020 07:16
-
-
Save JhonatanHern/2421fc23a393626c40403acaedbb5bc0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const { spawn } = require('child_process') | |
let holocServer = null, | |
reactServer = null, | |
holoData = '', | |
reacData = '' | |
process.chdir('frontend') | |
reactServer = spawn('npm',['start']) | |
process.chdir('../backend') | |
holocServer = spawn('node',['holo-server.js']) | |
process.chdir('..') | |
function display() { | |
console.log("\x1b[35m",'holo-server:') | |
console.log('\x1b[33m%s\x1b[0m', holoData) | |
console.log("\x1b[35m",'React-server:') | |
console.log("\x1b[36m",reacData) | |
} | |
holocServer.stdout.on('data', (chunk) => { | |
console.clear() | |
holoData = chunk.toString() | |
display() | |
}) | |
holocServer.stderr.on('data', (chunk) => { | |
console.clear() | |
holoData = chunk.toString() | |
display() | |
}) | |
reactServer.stdout.on('data', (chunk) => { | |
console.clear() | |
reacData = chunk.toString() | |
display() | |
}) | |
reactServer.on('error', (err) => { | |
console.log('Failed to start subprocess.') | |
}) | |
reactServer.on('warning', (warning) => { | |
console.warn(warning.name) | |
console.warn(warning.message) | |
console.warn(warning.code) | |
console.warn(warning.stack) | |
}) | |
holocServer.on('warning', (warning) => { | |
console.warn(warning.name) | |
console.warn(warning.message) | |
console.warn(warning.code) | |
console.warn(warning.stack) | |
}) | |
process.on('exit',()=>{ | |
holocServer.kill('SIGHUP') | |
reactServer.kill('SIGHUP') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment