Skip to content

Commit

Permalink
fix(core): improve error handling for copy and remove (#18656)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cammisuli committed Aug 16, 2023
1 parent f670e74 commit 13925ba
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/nx/src/native/cache/file_ops.rs
Original file line number Diff line number Diff line change
@@ -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]
Expand All @@ -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, &copy_options)?;
fs_extra::copy_items(&[src], dest_parent, &copy_options).map_err(|err| match err.kind {
ErrorKind::Io(err_kind) => anyhow::Error::new(err_kind),
_ => anyhow::Error::new(err),
})?;

Ok(())
}

Expand Down

1 comment on commit 13925ba

@vercel
Copy link

@vercel vercel bot commented on 13925ba Aug 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-git-master-nrwl.vercel.app
nx-five.vercel.app
nx-dev-nrwl.vercel.app
nx.dev

Please sign in to comment.