mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-03 10:11:15 +02:00
chore(bundler) show scripts output (#728)
This commit is contained in:
committed by
GitHub
parent
177f66d32a
commit
a5e7249178
@@ -15,7 +15,6 @@ mod tauri_config;
|
||||
#[cfg(target_os = "windows")]
|
||||
mod wix;
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
pub use self::common::print_info;
|
||||
pub use self::common::{print_error, print_finished};
|
||||
pub use self::settings::{PackageType, Settings};
|
||||
|
||||
@@ -88,19 +88,12 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
|
||||
.expect("Failed to chmod script");
|
||||
|
||||
// execute the shell script to build the appimage.
|
||||
let status = Command::new(&sh_file)
|
||||
.current_dir(output_path)
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
.status()
|
||||
.expect("Failed to execute shell script");
|
||||
let mut cmd = Command::new(&sh_file);
|
||||
cmd.current_dir(output_path);
|
||||
|
||||
if !status.success() {
|
||||
Err(crate::Error::ShellScriptError(
|
||||
"error running build_appimage.sh".to_owned(),
|
||||
))
|
||||
} else {
|
||||
remove_dir_all(&package_dir)?;
|
||||
Ok(vec![appimage_path])
|
||||
}
|
||||
common::execute_with_output(&mut cmd)
|
||||
.map_err(|_| crate::Error::ShellScriptError("error running build_appimage.sh".to_owned()))?;
|
||||
|
||||
remove_dir_all(&package_dir)?;
|
||||
Ok(vec![appimage_path])
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
use std;
|
||||
use std::ffi::OsStr;
|
||||
use std::fs::{self, File};
|
||||
use std::io::{self, BufWriter, Write};
|
||||
use std::io::{self, BufRead, BufReader, BufWriter, Write};
|
||||
use std::path::{Component, Path, PathBuf};
|
||||
use std::process::{Command, Stdio};
|
||||
|
||||
use term;
|
||||
use walkdir;
|
||||
@@ -214,7 +215,6 @@ pub fn print_warning(message: &str) -> crate::Result<()> {
|
||||
}
|
||||
|
||||
/// Prints a Info message to stderr.
|
||||
#[cfg(windows)]
|
||||
pub fn print_info(message: &str) -> crate::Result<()> {
|
||||
if let Some(mut output) = term::stderr() {
|
||||
safe_term_attr(&mut output, term::Attr::Bold)?;
|
||||
@@ -267,6 +267,28 @@ pub fn print_error(error: &anyhow::Error) -> crate::Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn execute_with_output(cmd: &mut Command) -> crate::Result<()> {
|
||||
let mut child = cmd
|
||||
.stdout(Stdio::piped())
|
||||
.spawn()
|
||||
.expect("failed to spawn command");
|
||||
{
|
||||
let stdout = child.stdout.as_mut().expect("Failed to get stdout handle");
|
||||
let reader = BufReader::new(stdout);
|
||||
|
||||
for line in reader.lines() {
|
||||
print_info(line.expect("Failed to get line").as_str())?;
|
||||
}
|
||||
}
|
||||
|
||||
let status = child.wait()?;
|
||||
if status.success() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(anyhow::anyhow!("command failed").into())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{copy_dir, create_file, is_retina, resource_relpath, symlink_file};
|
||||
|
||||
@@ -105,19 +105,15 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
|
||||
}
|
||||
|
||||
// execute the bundle script
|
||||
let status = Command::new(&bundle_script_path)
|
||||
let mut cmd = Command::new(&bundle_script_path);
|
||||
cmd
|
||||
.current_dir(bundle_dir.clone())
|
||||
.args(args)
|
||||
.args(vec![dmg_name.as_str(), bundle_name.as_str()])
|
||||
.status()
|
||||
.expect("Failed to execute shell script");
|
||||
.args(vec![dmg_name.as_str(), bundle_name.as_str()]);
|
||||
|
||||
if !status.success() {
|
||||
Err(crate::Error::ShellScriptError(
|
||||
"error running bundle_dmg.sh".to_owned(),
|
||||
))
|
||||
} else {
|
||||
fs::rename(bundle_dir.join(dmg_name.clone()), dmg_path.clone())?;
|
||||
Ok(vec![bundle_path, dmg_path])
|
||||
}
|
||||
common::execute_with_output(&mut cmd)
|
||||
.map_err(|_| crate::Error::ShellScriptError("error running bundle_dmg.sh".to_owned()))?;
|
||||
|
||||
fs::rename(bundle_dir.join(dmg_name.clone()), dmg_path.clone())?;
|
||||
Ok(vec![bundle_path, dmg_path])
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
mkdir -p {{app_name}}.AppDir
|
||||
cp -r ../deb/{{bundle_name}}/data/usr {{app_name}}.AppDir
|
||||
|
||||
|
||||
@@ -342,27 +342,13 @@ fn run_candle(
|
||||
let candle_exe = wix_toolset_path.join("candle.exe");
|
||||
common::print_info(format!("running candle for {}", wxs_file_name).as_str())?;
|
||||
|
||||
let mut cmd = Command::new(&candle_exe)
|
||||
let mut cmd = Command::new(&candle_exe);
|
||||
cmd
|
||||
.args(&args)
|
||||
.stdout(Stdio::piped())
|
||||
.current_dir(build_path)
|
||||
.spawn()
|
||||
.expect("error running candle.exe");
|
||||
{
|
||||
let stdout = cmd.stdout.as_mut().expect("Failed to get stdout handle");
|
||||
let reader = BufReader::new(stdout);
|
||||
.current_dir(build_path);
|
||||
|
||||
for line in reader.lines() {
|
||||
common::print_info(line.expect("Failed to get line").as_str())?;
|
||||
}
|
||||
}
|
||||
|
||||
let status = cmd.wait()?;
|
||||
if status.success() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(crate::Error::CandleError)
|
||||
}
|
||||
common::execute_with_output(&mut cmd).map_err(|_| crate::Error::CandleError)
|
||||
}
|
||||
|
||||
/// Runs the Light.exe file. Light takes the generated code from Candle and produces an MSI Installer.
|
||||
@@ -387,27 +373,15 @@ fn run_light(
|
||||
|
||||
common::print_info(format!("running light to produce {}", output_path.display()).as_str())?;
|
||||
|
||||
let mut cmd = Command::new(&light_exe)
|
||||
let mut cmd = Command::new(&light_exe);
|
||||
cmd
|
||||
.args(&args)
|
||||
.stdout(Stdio::piped())
|
||||
.current_dir(build_path)
|
||||
.spawn()
|
||||
.expect("error running light.exe");
|
||||
{
|
||||
let stdout = cmd.stdout.as_mut().expect("Failed to get stdout handle");
|
||||
let reader = BufReader::new(stdout);
|
||||
.current_dir(build_path);
|
||||
|
||||
for line in reader.lines() {
|
||||
common::print_info(line.expect("Failed to get line").as_str())?;
|
||||
}
|
||||
}
|
||||
|
||||
let status = cmd.wait()?;
|
||||
if status.success() {
|
||||
Ok(output_path.to_path_buf())
|
||||
} else {
|
||||
Err(crate::Error::LightError)
|
||||
}
|
||||
common::execute_with_output(&mut cmd)
|
||||
.map(|_| output_path.to_path_buf())
|
||||
.map_err(|_| crate::Error::LightError)
|
||||
}
|
||||
|
||||
// fn get_icon_data() -> crate::Result<()> {
|
||||
|
||||
Reference in New Issue
Block a user