Skip to content

Commit b658ded

Browse files
i-c-blucasfernog
andauthored
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>
1 parent 04440ed commit b658ded

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri-cli": patch:bug
3+
"@tauri-apps/cli": patch:bug
4+
---
5+
6+
Fixes truncation of existing BuildTask.kt when running `tauri android init`.

tooling/cli/src/mobile/android/project.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,9 @@ fn generate_out_file(
211211
options.mode(0o755);
212212
}
213213

214-
if path.file_name().unwrap() == OsStr::new("BuildTask.kt") || !path.exists() {
214+
if path.file_name().unwrap() == OsStr::new("BuildTask.kt") {
215+
options.truncate(true).create(true).open(path).map(Some)
216+
} else if !path.exists() {
215217
options.create(true).open(path).map(Some)
216218
} else {
217219
Ok(None)

tooling/cli/src/mobile/ios/project.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ pub fn gen(
155155
let mut options = OpenOptions::new();
156156
options.write(true);
157157

158-
if path.file_name().unwrap() == OsStr::new("BuildTask.kt") || !path.exists() {
158+
if !path.exists() {
159159
options.create(true).open(path).map(Some)
160160
} else {
161161
Ok(None)

tooling/cli/src/plugin/init.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ pub fn generate_android_out_file(
274274
options.mode(0o755);
275275
}
276276

277-
if path.file_name().unwrap() == OsStr::new("BuildTask.kt") || !path.exists() {
277+
if !path.exists() {
278278
options.create(true).open(path).map(Some)
279279
} else {
280280
Ok(None)

0 commit comments

Comments
 (0)