Skip to content

Commit 11112e8

Browse files
committed
chore: Update DumpPackageConfigExecutor to include packageJson in the response data
1 parent 3b616cc commit 11112e8

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/backend-runner/_executors/dump-package-config.executor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { BackendRunnerService } from '../backend-runner.service';
22
import { ExecutorExecuteResponseInterface, ExecutorInterface } from '../executors.interface';
33

44
export class DumpPackageConfigExecutor implements ExecutorInterface {
5-
public constructor(public service: BackendRunnerService) {}
5+
public constructor(public service: BackendRunnerService) { }
66

77
public async execute({ job }): Promise<ExecutorExecuteResponseInterface> {
88
return {
99
status: 0,
1010
jobId: job.id,
11-
data: [/*this.service.packageJson*/],
11+
data: [this.service.packageJson],
1212
};
1313
}
1414
}

src/backend-runner/backend-runner.service.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ import { ActionType } from './_enum/action-type.enum';
1010
import { ExecutorConfigInterface } from '~/_common/interfaces/executor-config.interface';
1111
import Redis from 'ioredis';
1212
import { 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()
1719
export 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

Comments
 (0)