diff --git a/src/cli/cli.rs b/src/cli/cli.rs index 2b5fb55..788002a 100644 --- a/src/cli/cli.rs +++ b/src/cli/cli.rs @@ -2,7 +2,6 @@ use std::{fs::read_to_string, process::ExitCode}; use anyhow::Result; use clap::{CommandFactory, Parser}; -use mlua::prelude::*; use lune::Lune; @@ -75,23 +74,18 @@ impl Cli { let download_types_requested = self.download_selene_types || self.download_luau_types; if download_types_requested { let client = GithubClient::new(); - let release = client - .fetch_release_for_this_version() - .await - .map_err(LuaError::external)?; + let release = client.fetch_release_for_this_version().await?; if self.download_selene_types { println!("Downloading Selene type definitions..."); client .fetch_release_asset(&release, LUNE_SELENE_FILE_NAME) - .await - .map_err(LuaError::external)?; + .await?; } if self.download_luau_types { println!("Downloading Luau type definitions..."); client .fetch_release_asset(&release, LUNE_LUAU_FILE_NAME) - .await - .map_err(LuaError::external)?; + .await?; } } if self.script_path.is_none() { @@ -127,16 +121,29 @@ impl Cli { #[cfg(test)] mod tests { - use super::{Cli, LUNE_LUAU_FILE_NAME, LUNE_SELENE_FILE_NAME}; + use std::{env::set_current_dir, time::Duration}; + use anyhow::{bail, Result}; use serde_json::Value; - use smol::fs::{create_dir_all, read_to_string}; - use std::env::set_current_dir; + use smol::{ + fs::{create_dir_all, read_to_string}, + Timer, + }; + + use super::{Cli, LUNE_LUAU_FILE_NAME, LUNE_SELENE_FILE_NAME}; + + async fn sleep(seconds: f32) -> Result<()> { + Timer::after(Duration::from_secs_f32(seconds)).await; + Ok(()) + } async fn run_cli(cli: Cli) -> Result<()> { create_dir_all("bin").await?; + sleep(0.125).await?; set_current_dir("bin")?; + sleep(0.125).await?; cli.run().await?; + sleep(0.125).await?; Ok(()) } diff --git a/src/lib/lib.rs b/src/lib/lib.rs index d84dedb..76b1abd 100644 --- a/src/lib/lib.rs +++ b/src/lib/lib.rs @@ -187,10 +187,12 @@ impl Lune { #[cfg(test)] mod tests { - use crate::Lune; + use std::process::ExitCode; + use anyhow::Result; use smol::fs::read_to_string; - use std::process::ExitCode; + + use crate::Lune; const ARGS: &[&str] = &["Foo", "Bar"];