Skip to content

Commit

Permalink
chore(cli): Fix conditional compilation for self_update command
Browse files Browse the repository at this point in the history
  • Loading branch information
theduke committed Jan 25, 2024
1 parent 0ff6cc9 commit 46e15c3
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions lib/cli/src/commands/self_update.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
//! When wasmer self-update is executed, this is what gets executed
#[cfg(not(target_os = "windows"))]
use std::process::{Command, Stdio};

use anyhow::{Context, Result};
use clap::Parser;
use anyhow::Context as _;

/// The options for the `wasmer self-update` subcommand
#[derive(Debug, Parser)]
#[derive(clap::Parser, Debug)]
pub struct SelfUpdate {}

impl SelfUpdate {
/// Runs logic for the `self-update` subcommand
pub fn execute(&self) -> Result<()> {
pub fn execute(&self) -> Result<(), anyhow::Error> {
self.inner_execute().context("failed to self-update wasmer")
}

#[cfg(not(target_os = "windows"))]
fn inner_execute(&self) -> Result<()> {
fn inner_execute(&self) -> Result<(), anyhow::Error> {
use std::process::{Command, Stdio};

println!("Fetching latest installer");
let cmd = Command::new("curl")
.arg("https://get.wasmer.io")
Expand All @@ -34,7 +31,7 @@ impl SelfUpdate {
}

#[cfg(target_os = "windows")]
fn inner_execute(&self) -> Result<()> {
bail!("Self update is not supported on Windows. Use install instructions on the Wasmer homepage: https://wasmer.io");
fn inner_execute(&self) -> Result<(), anyhow::Error> {
anyhow::bail!("Self update is not supported on Windows. Use install instructions on the Wasmer homepage: https://wasmer.io");
}
}

0 comments on commit 46e15c3

Please sign in to comment.