mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-01-31 00:35:19 +01:00
This commit is contained in:
committed by
GitHub
parent
fd5bb2c201
commit
32eb0d562b
5
.changes/command-shell.md
Normal file
5
.changes/command-shell.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"tauri-cli": patch
|
||||
---
|
||||
|
||||
Run `beforeDevCommand` and `beforeBuildCommand` in a shell.
|
||||
11
cli/core/Cargo.lock
generated
Normal file → Executable file
11
cli/core/Cargo.lock
generated
Normal file → Executable file
@@ -1963,7 +1963,6 @@ dependencies = [
|
||||
"toml_edit",
|
||||
"ureq",
|
||||
"valico",
|
||||
"which",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2370,16 +2369,6 @@ version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a32b378380f4e9869b22f0b5177c68a5519f03b3454fde0b291455ddbae266c"
|
||||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "4.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b55551e42cbdf2ce2bedd2203d0cc08dba002c27510f86dab6d0ce304cba3dfe"
|
||||
dependencies = [
|
||||
"either",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wildmatch"
|
||||
version = "1.1.0"
|
||||
|
||||
@@ -40,8 +40,5 @@ serde = { version = "1.0", features = [ "derive" ] }
|
||||
serde_json = "1.0"
|
||||
serde_with = "1.6"
|
||||
|
||||
[target."cfg(target_os = \"windows\")".dependencies]
|
||||
which = "4.0"
|
||||
|
||||
[target."cfg(target_os = \"linux\")".dependencies]
|
||||
heck = "0.3"
|
||||
|
||||
@@ -66,26 +66,22 @@ impl Build {
|
||||
}
|
||||
|
||||
if let Some(before_build) = &config_.build.before_build_command {
|
||||
let mut cmd: Option<&str> = None;
|
||||
let mut args: Vec<&str> = vec![];
|
||||
for token in before_build.split(' ') {
|
||||
if cmd.is_none() && !token.is_empty() {
|
||||
cmd = Some(token);
|
||||
} else {
|
||||
args.push(token)
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(cmd) = cmd {
|
||||
if !before_build.is_empty() {
|
||||
logger.log(format!("Running `{}`", before_build));
|
||||
#[cfg(target_os = "windows")]
|
||||
let mut command = Command::new(
|
||||
which::which(&cmd).expect(&format!("failed to find `{}` in your $PATH", cmd)),
|
||||
);
|
||||
execute_with_output(
|
||||
&mut Command::new("cmd")
|
||||
.arg("/C")
|
||||
.arg(before_build)
|
||||
.current_dir(app_dir()),
|
||||
)?;
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
let mut command = Command::new(cmd);
|
||||
command.args(args).current_dir(app_dir());
|
||||
execute_with_output(&mut command)?;
|
||||
execute_with_output(
|
||||
&mut Command::new("sh")
|
||||
.arg("-c")
|
||||
.arg(before_build)
|
||||
.current_dir(app_dir()),
|
||||
)?;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,25 +65,20 @@ impl Dev {
|
||||
.build
|
||||
.before_dev_command
|
||||
{
|
||||
let mut cmd: Option<&str> = None;
|
||||
let mut args: Vec<&str> = vec![];
|
||||
for token in before_dev.split(' ') {
|
||||
if cmd.is_none() && !token.is_empty() {
|
||||
cmd = Some(token);
|
||||
} else {
|
||||
args.push(token)
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(cmd) = cmd {
|
||||
if !before_dev.is_empty() {
|
||||
logger.log(format!("Running `{}`", before_dev));
|
||||
#[cfg(target_os = "windows")]
|
||||
let mut command = Command::new(
|
||||
which::which(&cmd).expect(&format!("failed to find `{}` in your $PATH", cmd)),
|
||||
);
|
||||
let child = Command::new("cmd")
|
||||
.arg("/C")
|
||||
.arg(before_dev)
|
||||
.current_dir(app_dir())
|
||||
.spawn()?;
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
let mut command = Command::new(cmd);
|
||||
let child = command.args(args).current_dir(app_dir()).spawn()?;
|
||||
let child = Command::new("sh")
|
||||
.arg("-c")
|
||||
.arg(before_dev)
|
||||
.current_dir(app_dir())
|
||||
.spawn()?;
|
||||
BEFORE_DEV.set(Mutex::new(child)).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user