From ea8eadce85b2e3e8eb7eb1a779fc3aa6c1201fa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E8=89=AF=E4=BB=94?= <32487868+cijiugechu@users.noreply.github.com> Date: Wed, 3 Jan 2024 02:44:09 +0800 Subject: [PATCH] fix(fs): match default value of `create` option with js documentation (#865) * fix(fs): inconsistency in guest-js & rust side * Update .changes/fix-fs-write-default-option.md --- .changes/fix-fs-write-default-option.md | 6 ++++++ plugins/fs/src/commands.rs | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changes/fix-fs-write-default-option.md diff --git a/.changes/fix-fs-write-default-option.md b/.changes/fix-fs-write-default-option.md new file mode 100644 index 00000000..01e6dc96 --- /dev/null +++ b/.changes/fix-fs-write-default-option.md @@ -0,0 +1,6 @@ +--- +"fs": "patch" +"fs-js": "patch" +--- + +Fix incorrect `create` option default value for `writeFile` and `writeTextFile` which didn't match documentation. \ No newline at end of file diff --git a/plugins/fs/src/commands.rs b/plugins/fs/src/commands.rs index d8e1f1fc..3e7bbd6d 100644 --- a/plugins/fs/src/commands.rs +++ b/plugins/fs/src/commands.rs @@ -585,7 +585,7 @@ pub struct WriteFileOptions { base: BaseOptions, #[serde(default)] append: bool, - #[serde(default)] + #[serde(default = "default_create_value")] create: bool, #[serde(default)] create_new: bool, @@ -593,6 +593,10 @@ pub struct WriteFileOptions { mode: Option, } +fn default_create_value() -> bool { + true +} + fn write_file_inner( app: AppHandle, path: SafePathBuf,