Skip to content

Commit

Permalink
wasm: return error for dry_run if we do not have window
Browse files Browse the repository at this point in the history
  • Loading branch information
amodm committed Apr 20, 2024
1 parent 0a55fdf commit 483e473
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ pub(super) fn open_browser_internal(

// always return true for a dry run
if options.dry_run {
return Ok(());
if let Some(_) = web_sys::window() {
return Ok(());
} else {
return Err(Error::new(ErrorKind::Other, "no browser window available"));
}
}

let window = web_sys::window();
Expand All @@ -30,10 +34,7 @@ pub(super) fn open_browser_internal(
Err(Error::new(ErrorKind::Other, "error opening url"))
}
},
None => Err(Error::new(
ErrorKind::Other,
"should have a window in this context",
)),
None => Err(Error::new(ErrorKind::Other, "no browser window available")),
}
}

Expand Down

0 comments on commit 483e473

Please sign in to comment.