5
5
import { Injectable , InternalServerErrorException } from '@nestjs/common' ;
6
6
import child_process from 'child_process' ;
7
7
import fs from 'fs' ;
8
+ import { Logger } from 'nestjs-pino' ;
8
9
import * as uuid from 'uuid' ;
9
10
import YAML from 'yaml' ;
10
11
import { LintErrorDTO } from './dto/lint-error.dto' ;
@@ -14,6 +15,8 @@ import { ConvertToPylintOutput } from './linters/pylint';
14
15
15
16
@Injectable ( )
16
17
export class LintService {
18
+ constructor ( private readonly logger : Logger ) { }
19
+
17
20
lintPython3 ( code : string ) : LintResultDTO {
18
21
const result = child_process . spawnSync (
19
22
'pylint' ,
@@ -24,13 +27,14 @@ export class LintService {
24
27
) ;
25
28
26
29
if ( result . error ) {
27
- throw new InternalServerErrorException ( ) ;
30
+ throw new InternalServerErrorException ( 'Failed to run pylint' ) ;
28
31
}
29
32
30
33
try {
31
34
let output = result . output . toString ( ) ;
32
35
output = output . substring ( 1 ) ;
33
36
output = output . substring ( 0 , output . length - 1 ) ;
37
+ this . logger . log ( output ) ;
34
38
const pylintOutput = ConvertToPylintOutput . toPylintOutput ( output ) ;
35
39
if ( pylintOutput ) {
36
40
/*
@@ -69,7 +73,7 @@ export class LintService {
69
73
} ;
70
74
}
71
75
} catch ( e ) {
72
- throw new InternalServerErrorException ( ) ;
76
+ throw new InternalServerErrorException ( e ) ;
73
77
}
74
78
75
79
throw new InternalServerErrorException ( ) ;
@@ -99,6 +103,7 @@ export class LintService {
99
103
let output = result . output . toString ( ) ;
100
104
output = output . substring ( 1 ) ;
101
105
output = output . substring ( 0 , output . length - 1 ) ;
106
+ this . logger . log ( output ) ;
102
107
const lintOuput =
103
108
ConvertToGolangCILintOutput . toGolangCILintOutput ( output ) ;
104
109
if ( lintOuput ) {
@@ -185,6 +190,7 @@ export class LintService {
185
190
if ( fs . existsSync ( outputPath ) ) {
186
191
const file = fs . readFileSync ( `${ path } .yaml` , 'utf8' ) ;
187
192
const fixes : any = YAML . parse ( file ) ;
193
+ this . logger . log ( fixes ) ;
188
194
189
195
if ( fixes ) {
190
196
/*
0 commit comments