55import { Injectable , InternalServerErrorException } from '@nestjs/common' ;
66import child_process from 'child_process' ;
77import fs from 'fs' ;
8+ import { Logger } from 'nestjs-pino' ;
89import * as uuid from 'uuid' ;
910import YAML from 'yaml' ;
1011import { LintErrorDTO } from './dto/lint-error.dto' ;
@@ -14,6 +15,8 @@ import { ConvertToPylintOutput } from './linters/pylint';
1415
1516@Injectable ( )
1617export class LintService {
18+ constructor ( private readonly logger : Logger ) { }
19+
1720 lintPython3 ( code : string ) : LintResultDTO {
1821 const result = child_process . spawnSync (
1922 'pylint' ,
@@ -24,13 +27,14 @@ export class LintService {
2427 ) ;
2528
2629 if ( result . error ) {
27- throw new InternalServerErrorException ( ) ;
30+ throw new InternalServerErrorException ( 'Failed to run pylint' ) ;
2831 }
2932
3033 try {
3134 let output = result . output . toString ( ) ;
3235 output = output . substring ( 1 ) ;
3336 output = output . substring ( 0 , output . length - 1 ) ;
37+ this . logger . log ( output ) ;
3438 const pylintOutput = ConvertToPylintOutput . toPylintOutput ( output ) ;
3539 if ( pylintOutput ) {
3640 /*
@@ -69,7 +73,7 @@ export class LintService {
6973 } ;
7074 }
7175 } catch ( e ) {
72- throw new InternalServerErrorException ( ) ;
76+ throw new InternalServerErrorException ( e ) ;
7377 }
7478
7579 throw new InternalServerErrorException ( ) ;
@@ -99,6 +103,7 @@ export class LintService {
99103 let output = result . output . toString ( ) ;
100104 output = output . substring ( 1 ) ;
101105 output = output . substring ( 0 , output . length - 1 ) ;
106+ this . logger . log ( output ) ;
102107 const lintOuput =
103108 ConvertToGolangCILintOutput . toGolangCILintOutput ( output ) ;
104109 if ( lintOuput ) {
@@ -185,6 +190,7 @@ export class LintService {
185190 if ( fs . existsSync ( outputPath ) ) {
186191 const file = fs . readFileSync ( `${ path } .yaml` , 'utf8' ) ;
187192 const fixes : any = YAML . parse ( file ) ;
193+ this . logger . log ( fixes ) ;
188194
189195 if ( fixes ) {
190196 /*
0 commit comments