fix(core): read nx.json in the DaemonClient constructor instead of the module (#23033)

This commit is contained in:
MaxKless 2024-04-26 16:42:12 +02:00 committed by GitHub
parent b8e6ebbf9a
commit d3454ede62
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -48,7 +48,13 @@ enum DaemonStatus {
}
export class DaemonClient {
constructor(private readonly nxJson: NxJsonConfiguration) {
private readonly nxJson: NxJsonConfiguration | null;
constructor() {
try {
this.nxJson = readNxJson();
} catch (e) {
this.nxJson = null;
}
this.reset();
}
@ -70,8 +76,8 @@ export class DaemonClient {
if (this._enabled === undefined) {
// TODO(v19): Add migration to move it out of existing configs and remove the ?? here.
const useDaemonProcessOption =
this.nxJson.useDaemonProcess ??
this.nxJson.tasksRunnerOptions?.['default']?.options?.useDaemonProcess;
this.nxJson?.useDaemonProcess ??
this.nxJson?.tasksRunnerOptions?.['default']?.options?.useDaemonProcess;
const env = process.env.NX_DAEMON;
// env takes precedence
@ -447,7 +453,7 @@ export class DaemonClient {
}
}
export const daemonClient = new DaemonClient(readNxJson());
export const daemonClient = new DaemonClient();
function isDocker() {
try {