Skip to content

Commit

Permalink
fix(cli): Truncate BuildTask.kt before writing (#9015)
Browse files Browse the repository at this point in the history
* truncate BuildTask.kt before write

* Create truncate-before-write-buildtask.md

* remove unused checks

---------

Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
  • Loading branch information
i-c-b and lucasfernog authored Feb 28, 2024
1 parent 04440ed commit b658ded
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changes/truncate-before-write-buildtask.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tauri-cli": patch:bug
"@tauri-apps/cli": patch:bug
---

Fixes truncation of existing BuildTask.kt when running `tauri android init`.
4 changes: 3 additions & 1 deletion tooling/cli/src/mobile/android/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ fn generate_out_file(
options.mode(0o755);
}

if path.file_name().unwrap() == OsStr::new("BuildTask.kt") || !path.exists() {
if path.file_name().unwrap() == OsStr::new("BuildTask.kt") {
options.truncate(true).create(true).open(path).map(Some)
} else if !path.exists() {
options.create(true).open(path).map(Some)
} else {
Ok(None)
Expand Down
2 changes: 1 addition & 1 deletion tooling/cli/src/mobile/ios/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pub fn gen(
let mut options = OpenOptions::new();
options.write(true);

if path.file_name().unwrap() == OsStr::new("BuildTask.kt") || !path.exists() {
if !path.exists() {
options.create(true).open(path).map(Some)
} else {
Ok(None)
Expand Down
2 changes: 1 addition & 1 deletion tooling/cli/src/plugin/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ pub fn generate_android_out_file(
options.mode(0o755);
}

if path.file_name().unwrap() == OsStr::new("BuildTask.kt") || !path.exists() {
if !path.exists() {
options.create(true).open(path).map(Some)
} else {
Ok(None)
Expand Down

0 comments on commit b658ded

Please sign in to comment.