| const { execSync, spawn } = require('child_process'); |
| const path = require('path'); |
|
|
| function runInstall(dir) { |
| console.log(`Installing dependencies in ${dir}...`); |
| execSync('npm install', { cwd: dir, stdio: 'inherit' }); |
| } |
|
|
| function runStart(dir, name) { |
| console.log(`Starting ${name}...`); |
| const child = spawn(/^win/.test(process.platform) ? 'npm.cmd' : 'npm', ['start'], { |
| cwd: dir, |
| stdio: 'inherit', |
| shell: true, |
| }); |
| child.on('close', code => { |
| console.log(`${name} exited with code ${code}`); |
| }); |
| } |
|
|
| const backendDir = path.join(__dirname, 'backend'); |
| const frontendDir = path.join(__dirname, 'frontend'); |
|
|
| runInstall(backendDir); |
| runInstall(frontendDir); |
|
|
| runStart(backendDir, 'Backend'); |
| runStart(frontendDir, 'Frontend'); |