summaryrefslogtreecommitdiff
path: root/cli/js/write_file.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/js/write_file.ts')
-rw-r--r--cli/js/write_file.ts12
1 files changed, 8 insertions, 4 deletions
diff --git a/cli/js/write_file.ts b/cli/js/write_file.ts
index ed64141d2..af3f67251 100644
--- a/cli/js/write_file.ts
+++ b/cli/js/write_file.ts
@@ -24,8 +24,10 @@ export function writeFileSync(
}
}
- const openMode = !!options.append ? "a" : "w";
- const file = openSync(path, openMode);
+ const openOptions = !!options.append
+ ? { write: true, create: true, append: true }
+ : { write: true, create: true, truncate: true };
+ const file = openSync(path, openOptions);
if (
options.mode !== undefined &&
@@ -52,8 +54,10 @@ export async function writeFile(
}
}
- const openMode = !!options.append ? "a" : "w";
- const file = await open(path, openMode);
+ const openOptions = !!options.append
+ ? { write: true, create: true, append: true }
+ : { write: true, create: true, truncate: true };
+ const file = await open(path, openOptions);
if (
options.mode !== undefined &&