-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
67 lines (52 loc) · 1.75 KB
/
index.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
const { getDetektReport, getKtlintReport } = require('./src/controller/linterManager')
const { spawn } = require('child_process')
const core = require('@actions/core')
const { writeReportDetekt, writeReportKtlint } = require('./src/controller/writeOutput')
function runDetekt() {
const command = './gradlew detekt'
const childProcess = spawn(command, { shell: true })
try {
childProcess.stderr.on('data', (data) => {
core.setFailed(`\u001b[38;5;6m[erro] EXEC -> Erro no comando bash: ${data}`)
})
childProcess.on('close', (code) => {
core.info('\u001b[38;5;6m[info] Iniciando análise do detekt')
report = getDetektReport()
core.setOutput('Detekt', JSON.stringify(report))
core.notice('\u001b[32;5;6m 🚀 DETEKT > Processo concluído')
writeReportDetekt(report)
return report
})
} catch (error) {
core.setOutput('Detekt', error)
core.setFailed(`${error}`)
return error
}
}
function runKtlint() {
const command = './gradlew ktlintCheck'
const childProcess = spawn(command, { shell: true })
try {
childProcess.stderr.on('data', (data) => {
core.setFailed(`\u001b[38;5;6m[erro] EXEC -> Erro no comando bash: ${data}`)
})
childProcess.on('close', (code) => {
core.info('\u001b[38;5;6m[info] Iniciando análise do ktlint')
report = getKtlintReport()
core.setOutput('result > ktlint', report)
core.notice('\u001b[32;5;6m 🚀 KTLINT > Processo concluído')
writeReportKtlint(report)
return report
})
} catch (error) {
core.setOutput('result > ktlint', error)
core.setFailed(`${error}`)
return error
}
}
const run = () => {
runDetekt()
runKtlint()
}
core.info('\u001b[38;5;6m[info] 🏃♂️ Rodando linter')
run()