Skip to content

Commit e09d93a

Browse files
committed
fix(opener): return error if path not exists
1 parent 1fe70dc commit e09d93a

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"opener": patch
3+
"opener-js": patch
4+
---
5+
`open_path` now returns an error if the file does not exist

plugins/opener/src/open.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,9 @@ pub fn open_url<P: AsRef<str>, S: AsRef<str>>(url: P, with: Option<S>) -> crate:
5353
/// ```
5454
pub fn open_path<P: AsRef<Path>, S: AsRef<str>>(path: P, with: Option<S>) -> crate::Result<()> {
5555
let path = path.as_ref();
56+
if with.is_none() {
57+
// Returns an IO error if not exists, and besides `exists()` is a shorthand for `metadata()`
58+
_ = path.metadata()?;
59+
}
5660
open(path, with)
5761
}

0 commit comments

Comments
 (0)