Skip to content

Commit 483e473

Browse files
committed
wasm: return error for dry_run if we do not have window
1 parent 0a55fdf commit 483e473

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/wasm.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ pub(super) fn open_browser_internal(
1212

1313
// always return true for a dry run
1414
if options.dry_run {
15-
return Ok(());
15+
if let Some(_) = web_sys::window() {
16+
return Ok(());
17+
} else {
18+
return Err(Error::new(ErrorKind::Other, "no browser window available"));
19+
}
1620
}
1721

1822
let window = web_sys::window();
@@ -30,10 +34,7 @@ pub(super) fn open_browser_internal(
3034
Err(Error::new(ErrorKind::Other, "error opening url"))
3135
}
3236
},
33-
None => Err(Error::new(
34-
ErrorKind::Other,
35-
"should have a window in this context",
36-
)),
37+
None => Err(Error::new(ErrorKind::Other, "no browser window available")),
3738
}
3839
}
3940

0 commit comments

Comments
 (0)