@@ -10,12 +10,14 @@ import { ActionType } from './_enum/action-type.enum';
1010import { ExecutorConfigInterface } from '~/_common/interfaces/executor-config.interface' ;
1111import Redis from 'ioredis' ;
1212import { DumpPackageConfigExecutor } from './_executors/dump-package-config.executor' ;
13+ import { PackageJson } from 'types-package-json' ;
14+ import { readFileSync } from 'node:fs' ;
1315//import { PackageJson } from 'types-package-json';
1416//import { readFileSync } from 'node:fs';
1517
1618@Injectable ( )
1719export class BackendRunnerService implements OnApplicationBootstrap , OnModuleInit {
18- // protected _package: Partial<PackageJson>;
20+ protected _package : Partial < PackageJson > ;
1921 private readonly _logger = new Logger ( BackendRunnerService . name ) ;
2022
2123 protected executors : Map < string , ExecutorInterface > = new Map < string , ExecutorInterface > ( ) ;
@@ -28,9 +30,9 @@ export class BackendRunnerService implements OnApplicationBootstrap, OnModuleIni
2830 return this . _logger ;
2931 }
3032
31- // public get packageJson(): Partial<PackageJson> {
32- // return this._package;
33- // }
33+ public get packageJson ( ) : Partial < PackageJson > {
34+ return this . _package ;
35+ }
3436
3537 public get backendExecutorConfig ( ) : ExecutorConfigInterface {
3638 return this . _config . get < ExecutorConfigInterface > ( 'application.backendExecutorConfig' ) ;
@@ -41,7 +43,13 @@ export class BackendRunnerService implements OnApplicationBootstrap, OnModuleIni
4143 private readonly _backendsConfig : BackendConfigService ,
4244 @InjectRedis ( ) private readonly redis : Redis ,
4345 ) {
44- // this._package = JSON.parse(readFileSync('package.json', 'utf-8'));
46+ try {
47+
48+ this . _package = JSON . parse ( readFileSync ( 'package.json' , 'utf-8' ) ) ;
49+ } catch ( e ) {
50+ this . _logger . error ( 'Error reading package.json file: ' , e ) ;
51+ this . _package = { } ;
52+ }
4553 }
4654
4755 public async onModuleInit ( ) {
0 commit comments