Skip to content

Commit a1f9c58

Browse files
committed
Update BackendRunnerService to handle different paths for reading package.json
1 parent 71b23d7 commit a1f9c58

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ 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 { readFileSync } from 'node:fs';
13+
import { existsSync, readFileSync } from 'node:fs';
1414
import { PackageJson } from 'types-package-json';
1515

1616
@Injectable()
@@ -43,7 +43,13 @@ export class BackendRunnerService implements OnApplicationBootstrap, OnModuleIni
4343
) {
4444
this._package = {};
4545
try {
46-
this._package = JSON.parse(readFileSync('/snapshot/data/package.json', 'utf-8'));
46+
if (existsSync('/snapshot/data/package.json')) {
47+
this._package = JSON.parse(readFileSync('/snapshot/data/package.json', 'utf-8'));
48+
} else if (existsSync('/snapshot/sesame-daemon/package.json')) {
49+
this._package = JSON.parse(readFileSync('/snapshot/sesame-daemon/package.json', 'utf-8'));
50+
} else {
51+
this._package = JSON.parse(readFileSync('package.json', 'utf-8'));
52+
}
4753
} catch (e) {
4854
this._logger.error('Error reading package.json file: ', e);
4955
this._package = {};

0 commit comments

Comments
 (0)