Skip to content

Commit e76ebea

Browse files
committed
fix(opener): return error if path not exists
1 parent 97795f4 commit e76ebea

File tree

2 files changed

+5
-2
lines changed

2 files changed

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

plugins/opener/src/open.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +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-
// Returns an IO error if not exists, and besides `exists()` is a shorthand for `metadata()`
57-
_ = path.metadata()?;
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+
}
5860
open(path, with)
5961
}

0 commit comments

Comments
 (0)