diff --git a/packages/nx/bin/post-install.ts b/packages/nx/bin/post-install.ts index acaffa0ea4565..b7193d5d8acba 100644 --- a/packages/nx/bin/post-install.ts +++ b/packages/nx/bin/post-install.ts @@ -8,9 +8,11 @@ import { verifyOrUpdateNxCloudClient } from '../src/nx-cloud/update-manager'; import { getCloudOptions } from '../src/nx-cloud/utilities/get-cloud-options'; import { isNxCloudUsed } from '../src/utils/nx-cloud-utils'; import { readNxJson } from '../src/config/nx-json'; +import { setupWorkspaceContext } from '../src/utils/workspace-context'; (async () => { try { + setupWorkspaceContext(workspaceRoot); if (isMainNxPackage() && fileExists(join(workspaceRoot, 'nx.json'))) { const b = new Date(); assertSupportedPlatform(); diff --git a/packages/nx/src/native/workspace/context.rs b/packages/nx/src/native/workspace/context.rs index 717865ebcfc08..0dc7bfee6e28e 100644 --- a/packages/nx/src/native/workspace/context.rs +++ b/packages/nx/src/native/workspace/context.rs @@ -65,13 +65,14 @@ impl FilesWorker { FilesWorker(Some(files_lock)) } - pub fn get_files(&self) -> Option> { + pub fn get_files(&self) -> Option> { let Some(files_sync) = &self.0 else { trace!("there were no files because the workspace root did not exist"); return None; }; let (files_lock, cvar) = &files_sync.deref(); + trace!("locking files"); let mut files = files_lock.lock(); let files_len = files.len(); if files_len == 0 { @@ -79,8 +80,11 @@ impl FilesWorker { cvar.wait(&mut files); } + let cloned_files = files.clone(); + drop(files); + trace!("files are available"); - Some(files) + Some(cloned_files) } pub fn update_files( @@ -156,22 +160,13 @@ impl WorkspaceContext { workspace_files::get_files( globs, parse_configurations, - self.files_worker - .get_files() - .as_deref() - .map(|files| files.as_slice()), + self.files_worker.get_files().as_deref(), ) } #[napi] pub fn glob(&self, globs: Vec) -> napi::Result, WorkspaceErrors> { - config_files::glob_files( - globs, - self.files_worker - .get_files() - .as_deref() - .map(|files| files.as_slice()), - ) + config_files::glob_files(globs, self.files_worker.get_files().as_deref()) } #[napi] @@ -185,10 +180,7 @@ impl WorkspaceContext { { config_files::get_project_configurations( globs, - self.files_worker - .get_files() - .as_deref() - .map(|files| files.as_slice()), + self.files_worker.get_files().as_deref(), parse_configurations, ) }