Skip to content

Commit

Permalink
fix: clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
amr-crabnebula committed Sep 6, 2023
1 parent 8309a63 commit 783603b
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
6 changes: 3 additions & 3 deletions crates/packager/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl ConfigExtInternal for Config {
src.ok().and_then(|src| {
use relative_path::PathExt;
let src =
dunce::canonicalize(&src).expect("failed to canonicalize path");
dunce::canonicalize(src).expect("failed to canonicalize path");
let target = src.relative_to(&cwd);
target.ok().map(|target| Resource {
src,
Expand All @@ -101,10 +101,10 @@ impl ConfigExtInternal for Config {
}
Resources::Map(m) => {
for (src, target) in m.iter() {
out.extend(glob::glob(&src).unwrap().filter_map(|src| {
out.extend(glob::glob(src).unwrap().filter_map(|src| {
src.ok().map(|src| {
let src =
dunce::canonicalize(&src).expect("failed to canonicalize path");
dunce::canonicalize(src).expect("failed to canonicalize path");
let target = PathBuf::from(target).join(
src.file_name()
.expect("Failed to get filename of a resource file"),
Expand Down
2 changes: 1 addition & 1 deletion crates/packager/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub enum Error {
ZipError(#[from] zip::result::ZipError),
/// Zip error.
#[error(transparent)]
DownloadError(#[from] ureq::Error),
DownloadError(#[from] Box<ureq::Error>),
/// Unsupported OS bitness.
#[error("unsupported OS bitness")]
UnsupportedBitness,
Expand Down
12 changes: 6 additions & 6 deletions crates/packager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ fn cross_command(script: &str) -> Command {
#[cfg(windows)]
let mut cmd = Command::new("cmd");
#[cfg(windows)]
cmd.arg("/S").arg("/C").arg(&script);
cmd.arg("/S").arg("/C").arg(script);
#[cfg(not(windows))]
let mut cmd = Command::new("sh");
#[cfg(not(windows))]
cmd.arg("-c").arg(&script);
cmd.arg("-c").arg(script);
cmd
}

Expand All @@ -100,11 +100,11 @@ pub fn package(config: &Config) -> Result<Vec<Package>> {
if let Some(hook) = &config.before_packaging_command {
let (mut cmd, script) = match hook {
cargo_packager_config::HookCommand::Script(script) => {
let cmd = cross_command(&script);
let cmd = cross_command(script);
(cmd, script)
}
cargo_packager_config::HookCommand::ScriptWithOptions { script, dir } => {
let mut cmd = cross_command(&script);
let mut cmd = cross_command(script);
if let Some(dir) = dir {
cmd.current_dir(dir);
}
Expand All @@ -129,11 +129,11 @@ pub fn package(config: &Config) -> Result<Vec<Package>> {
if let Some(hook) = &config.before_each_package_command {
let (mut cmd, script) = match hook {
cargo_packager_config::HookCommand::Script(script) => {
let cmd = cross_command(&script);
let cmd = cross_command(script);
(cmd, script)
}
cargo_packager_config::HookCommand::ScriptWithOptions { script, dir } => {
let mut cmd = cross_command(&script);
let mut cmd = cross_command(script);
if let Some(dir) = dir {
cmd.current_dir(dir);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/packager/src/nsis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn generate_binaries_data(config: &Config) -> crate::Result<BinariesMap> {

if let Some(external_binaries) = &config.external_binaries {
for src in external_binaries {
let binary_path = dunce::canonicalize(cwd.join(&src))?;
let binary_path = dunce::canonicalize(cwd.join(src))?;
let dest_filename = binary_path
.file_name()
.expect("failed to extract external binary filename")
Expand Down
2 changes: 1 addition & 1 deletion crates/packager/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub fn target_triple() -> crate::Result<String> {

pub(crate) fn download(url: &str) -> crate::Result<Vec<u8>> {
log::info!(action = "Downloading"; "{}", url);
let response = ureq::get(url).call()?;
let response = ureq::get(url).call().map_err(Box::new)?;
let mut bytes = Vec::new();
response.into_reader().read_to_end(&mut bytes)?;
Ok(bytes)
Expand Down
9 changes: 6 additions & 3 deletions crates/packager/src/wix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ fn generate_binaries_data(config: &Config) -> crate::Result<Vec<Binary>> {

if let Some(external_binaries) = &config.external_binaries {
for src in external_binaries {
let binary_path = cwd.join(&src);
let binary_path = cwd.join(src);
let dest_filename = PathBuf::from(src)
.file_name()
.expect("failed to extract external binary filename")
Expand Down Expand Up @@ -411,14 +411,18 @@ fn clear_env_for_wix(cmd: &mut Command) {
/// Runs the Candle.exe executable for Wix. Candle parses the wxs file and generates the code for building the installer.
fn run_candle(
config: &Config,
main_binary: &crate::config::Binary,
arch: &str,
wix_toolset_path: &Path,
cwd: &Path,
wxs_file_path: PathBuf,
extensions: Vec<PathBuf>,
log_level: LogLevel,
) -> crate::Result<()> {
let main_binary = config
.binaries
.iter()
.find(|bin| bin.main)
.ok_or_else(|| crate::Error::MainBinaryNotFound)?;
let mut args = vec![
"-arch".to_string(),
arch.to_string(),
Expand Down Expand Up @@ -747,7 +751,6 @@ fn build_wix_app_installer(
}
run_candle(
config,
main_binary,
arch,
wix_toolset_path,
&output_path,
Expand Down

0 comments on commit 783603b

Please sign in to comment.