From 6329507338c4f6a71067bf31d4f5336547c6bec4 Mon Sep 17 00:00:00 2001 From: Muhammad Hamza Date: Sat, 10 Jun 2023 17:00:21 +0500 Subject: [PATCH] cargo fmt + ci fix --- src/command/build.rs | 2 +- src/command/mod.rs | 4 ++-- src/command/test.rs | 4 ++-- src/lib.rs | 8 ++++---- src/main.rs | 4 ++-- src/readme.rs | 19 ++++++++++++------- 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/command/build.rs b/src/command/build.rs index ad50e081..37a018b8 100644 --- a/src/command/build.rs +++ b/src/command/build.rs @@ -14,12 +14,12 @@ use crate::wasm_opt; use crate::PBAR; use anyhow::{anyhow, bail, Error, Result}; use binary_install::Cache; +use clap::Args; use log::info; use std::fmt; use std::path::PathBuf; use std::str::FromStr; use std::time::Instant; -use clap::{Args}; /// Everything required to configure and run the `wasm-pack build` command. #[allow(missing_docs)] diff --git a/src/command/mod.rs b/src/command/mod.rs index dad39f40..c3e4edff 100644 --- a/src/command/mod.rs +++ b/src/command/mod.rs @@ -18,10 +18,10 @@ use self::publish::{access::Access, publish}; use self::test::{Test, TestOptions}; use crate::install::InstallMode; use anyhow::Result; +use clap::builder::ValueParser; +use clap::Subcommand; use log::info; use std::path::PathBuf; -use clap::Subcommand; -use clap::builder::ValueParser; /// The various kinds of commands that `wasm-pack` can execute. #[derive(Debug, Subcommand)] pub enum Command { diff --git a/src/command/test.rs b/src/command/test.rs index c0939746..30b0e5ff 100644 --- a/src/command/test.rs +++ b/src/command/test.rs @@ -9,13 +9,13 @@ use crate::manifest; use crate::test::{self, webdriver}; use anyhow::{bail, Result}; use binary_install::Cache; +use clap::builder::ValueParser; +use clap::Args; use console::style; use log::info; use std::path::PathBuf; use std::str::FromStr; use std::time::Instant; -use clap::Args; -use clap::builder::ValueParser; #[derive(Debug, Default, Args)] #[command(allow_hyphen_values = true, trailing_var_arg = true)] diff --git a/src/lib.rs b/src/lib.rs index af66554d..e0df8b36 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,12 +13,12 @@ extern crate strsim; extern crate which; #[macro_use] extern crate serde_derive; -extern crate serde_ignored; -extern crate serde_json; extern crate binary_install; extern crate chrono; extern crate dialoguer; extern crate log; +extern crate serde_ignored; +extern crate serde_json; extern crate toml; extern crate walkdir; @@ -41,9 +41,9 @@ pub mod target; pub mod test; pub mod wasm_opt; -use clap::Parser; -use clap::builder::ArgAction; use crate::progressbar::{LogLevel, ProgressOutput}; +use clap::builder::ArgAction; +use clap::Parser; /// The global progress bar and user-facing message output. pub static PBAR: ProgressOutput = ProgressOutput::new(); diff --git a/src/main.rs b/src/main.rs index 048561aa..e8e0754c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,19 +2,19 @@ extern crate anyhow; extern crate atty; +extern crate clap; extern crate env_logger; extern crate human_panic; extern crate log; -extern crate clap; extern crate wasm_pack; extern crate which; use anyhow::Result; +use clap::Parser; use std::env; use std::panic; use std::sync::mpsc; use std::thread; -use clap::Parser; use wasm_pack::{ build::{self, WasmPackVersion}, command::run_wasm_pack, diff --git a/src/readme.rs b/src/readme.rs index d82f5b3f..6738e023 100644 --- a/src/readme.rs +++ b/src/readme.rs @@ -1,6 +1,6 @@ //! Generating `README` files for the packaged wasm. -use anyhow::{Context, Result}; +use anyhow::{bail, Context, Result}; use std::fs; use std::path::Path; @@ -18,16 +18,21 @@ pub fn copy_from_crate(crate_data: &CrateData, path: &Path, out_dir: &Path) -> R "crate's pkg directory should exist" ); - let crate_readme_path = match crate_data.crate_readme() { - None => return Ok(()), + let crate_readme_path = match dbg!(crate_data.crate_readme()) { + None => { + PBAR.warn("origin crate has no README"); + return Ok(()); + } Some(readme_path) => path.join(readme_path), }; let new_readme_path = out_dir.join("README.md"); - if crate_readme_path.exists() { - fs::copy(&crate_readme_path, &new_readme_path).context("failed to copy README")?; - } else { - PBAR.warn("origin crate has no README"); + if !(crate_readme_path.exists()) { + bail!( + "crate's README does not exist at {}", + crate_readme_path.display() + ) } + fs::copy(&crate_readme_path, &new_readme_path).context("failed to copy README")?; Ok(()) }