forked from RyanCastle1/1.13-full-stack-project-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbin.js
More file actions
24 lines (20 loc) · 787 Bytes
/
bin.js
File metadata and controls
24 lines (20 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const { spawn: nativeSpawn } = require('child_process')
const Path = require('path')
let main = async () => {
console.log('Installing backend dependencies')
await spawn('./backend', `npm`, 'install')
console.log('Starting backend')
spawn('./backend',`npm`, 'start')
await sleep(1000)
console.log('Installing frontend dependencies')
await spawn('./frontend',`npm`, 'install')
console.log('Starting frontend')
spawn('./frontend',`npm`, 'start')
}
let spawn = (relativePath, command, ...args) => new Promise(resolve => {
const cwd = Path.resolve(relativePath)
const process = nativeSpawn(command, args, { cwd, stdio: 'inherit'})
process.on('close', resolve)
})
let sleep = time => new Promise( resolve => setTimeout(resolve, time))
main()