-
Notifications
You must be signed in to change notification settings - Fork 0
/
formatAndLint.js
84 lines (82 loc) · 2.81 KB
/
formatAndLint.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
var cp = require('child_process')
var path = require('path')
const chalk = require('chalk')
console.log('Formatting and linting...')
console.log('Starting formatting backend.')
const backendFormat = cp.spawn('yarn', ['format:all'], {
cwd: path.join(__dirname, '/backend'),
})
backendFormat.stdout.on('data', (data) => {
console.log('formatting backend: ' + data.toString())
})
backendFormat.stderr.on('data', (data) => {
console.error(chalk.red('backend formatting error: ' + data.toString()))
})
backendFormat.on('exit', (code) => {
console.log('backend formatted')
setTimeout(() => {
console.log('Starting linting backend.')
const backendLint = cp.spawn('yarn', ['lint:all'], {
cwd: path.join(__dirname, '/backend'),
})
backendLint.stdout.on('data', (data) => {
if (data.includes('warning')) {
console.warn(chalk.yellow('backend linting error: ' + data.toString()))
} else {
console.log('linting backend: ' + data.toString())
}
})
backendLint.stderr.on('data', (data) => {
console.error(chalk.red('backend linting error: ' + data.toString()))
})
backendLint.on('exit', (code) => {
if (code !== 0) {
process.exitCode = 1
}
console.log('backend linted')
setTimeout(() => {
console.log('Starting formatting frontend.')
const frontendFormat = cp.spawn('yarn', ['format:all'], {
cwd: path.join(__dirname, '/frontend'),
})
frontendFormat.stdout.on('data', (data) => {
console.log('formatting frontend: ' + data.toString())
})
frontendFormat.stderr.on('data', (data) => {
console.error(
chalk.red('frontend formatting error: ' + data.toString())
)
})
frontendFormat.on('exit', (code) => {
console.log('frontend formatted')
setTimeout(() => {
console.log('Starting linting frontend.')
const frontendLint = cp.spawn('yarn', ['lint:all'], {
cwd: path.join(__dirname, '/frontend'),
})
frontendLint.stdout.on('data', (data) => {
if (data.includes('warning')) {
console.warn(
chalk.yellow('frontend linting error: ' + data.toString())
)
} else {
console.log('linting frontend: ' + data.toString())
}
})
frontendLint.stderr.on('data', (data) => {
console.error(
chalk.red('frontend linting error: ' + data.toString())
)
})
frontendLint.on('exit', (code) => {
if (code !== 0) {
process.exitCode = 1
}
console.log('frontend linted')
})
}, 100)
})
}, 100)
})
}, 100)
})