-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
46 lines (44 loc) · 1.28 KB
/
build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
var cp = require('child_process')
var path = require('path')
const chalk = require('chalk')
console.log('Starting...')
console.log('Starting backend compilation.')
const backend = cp.spawn('yarn', ['build'], {
cwd: path.join(__dirname, '/backend'),
})
backend.stdout.on('data', (data) => {
console.log('backend compilation: ' + data.toString())
})
backend.stderr.on('data', (data) => {
console.error(chalk.red('backend compilation error: ' + data.toString()))
})
backend.on('exit', (code) => {
if (code === 0) {
console.log('backend compiled')
} else {
console.error(
chalk.red('backend failed compiling with code ' + code.toString())
)
process.exitCode = 1
}
console.log('Starting building frontend.')
const frontend = cp.spawn('yarn', ['build'], {
cwd: path.join(__dirname, '/frontend'),
})
frontend.stdout.on('data', (data) => {
console.log('building frontend: ' + data.toString())
})
frontend.stderr.on('data', (data) => {
console.error(chalk.red('frontend building error: ' + data.toString()))
})
frontend.on('exit', (code) => {
if (code === 0) {
console.log('frontend built')
} else {
console.error(
chalk.red('frontend failed building with code ' + code.toString())
)
process.exitCode = 1
}
})
})