diff --git a/packages/nx/src/native/cache/file_ops.rs b/packages/nx/src/native/cache/file_ops.rs index cafdfbfd068cf..4fe9b31f4b303 100644 --- a/packages/nx/src/native/cache/file_ops.rs +++ b/packages/nx/src/native/cache/file_ops.rs @@ -1,9 +1,14 @@ use std::fs; use std::path::PathBuf; +use fs_extra::error::ErrorKind; + #[napi] pub fn remove(src: String) -> anyhow::Result<()> { - fs_extra::remove_items(&[src]).map_err(anyhow::Error::from) + fs_extra::remove_items(&[src]).map_err(|err| match err.kind { + ErrorKind::Io(err_kind) => anyhow::Error::new(err_kind), + _ => anyhow::Error::new(err), + }) } #[napi] @@ -19,7 +24,11 @@ pub fn copy(src: String, dest: String) -> anyhow::Result<()> { fs::create_dir_all(dest_parent)?; } - fs_extra::copy_items(&[src], dest_parent, ©_options)?; + fs_extra::copy_items(&[src], dest_parent, ©_options).map_err(|err| match err.kind { + ErrorKind::Io(err_kind) => anyhow::Error::new(err_kind), + _ => anyhow::Error::new(err), + })?; + Ok(()) }