fix(cli): Truncate BuildTask.kt before writing (#9015)

* truncate BuildTask.kt before write

* Create truncate-before-write-buildtask.md

* remove unused checks

---------

Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
This commit is contained in:
i-c-b 2024-02-28 11:42:21 -05:00 committed by GitHub
parent 04440edce8
commit b658ded614
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 3 deletions

View File

@ -0,0 +1,6 @@
---
"tauri-cli": patch:bug
"@tauri-apps/cli": patch:bug
---
Fixes truncation of existing BuildTask.kt when running `tauri android init`.

View File

@ -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)

View File

@ -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)

View File

@ -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)