mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-11-24 04:03:52 +03:00
feat(cli): allow skipping rustfmt project reformatting when adding a plugin (#10457)
* feat(cli): allow skipping rustfmt project reformatting * Apply suggestions from code review * fixes, change file * fix change file --------- Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app>
This commit is contained in:
parent
92cac12a92
commit
bba1a44191
6
.changes/cli-add-no-fmt.md
Normal file
6
.changes/cli-add-no-fmt.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
"tauri-cli": "patch:enhance"
|
||||
"@tauri-apps/cli": "patch:enhance"
|
||||
---
|
||||
|
||||
Added `--no-fmt` option to the `add` command to skip formatting the code after applying changes.
|
@ -86,6 +86,9 @@ pub struct Options {
|
||||
/// Git branch to use.
|
||||
#[clap(short, long)]
|
||||
pub branch: Option<String>,
|
||||
/// Don't format code with rustfmt
|
||||
#[clap(long)]
|
||||
pub no_fmt: bool,
|
||||
}
|
||||
|
||||
pub fn command(options: Options) -> Result<()> {
|
||||
@ -185,12 +188,15 @@ pub fn command(options: Options) -> Result<()> {
|
||||
log::info!("Adding plugin to {}", file.display());
|
||||
std::fs::write(file, out.as_bytes())?;
|
||||
|
||||
// run cargo fmt
|
||||
log::info!("Running `cargo fmt`...");
|
||||
let _ = Command::new("cargo")
|
||||
.arg("fmt")
|
||||
.current_dir(&tauri_dir)
|
||||
.status();
|
||||
if !options.no_fmt {
|
||||
// reformat code with rustfmt
|
||||
log::info!("Running `cargo fmt`...");
|
||||
let _ = Command::new("cargo")
|
||||
.arg("fmt")
|
||||
.current_dir(&tauri_dir)
|
||||
.status();
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ pub fn run() -> Result<()> {
|
||||
branch: None,
|
||||
tag: None,
|
||||
rev: None,
|
||||
no_fmt: false,
|
||||
})
|
||||
.with_context(|| format!("Could not migrate plugin '{plugin}'"))?;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user