aboutsummaryrefslogtreecommitdiff
path: root/docs/guides/write-file/unlink.md
diff options
context:
space:
mode:
authorGravatar Colin McDonnell <colinmcd94@gmail.com> 2023-07-31 12:20:23 -0700
committerGravatar GitHub <noreply@github.com> 2023-07-31 12:20:23 -0700
commit404b90badc5856a74c06d04062c850003e28fed5 (patch)
tree7954623cf4a792db612d0bb229a227c2ff1e9fd8 /docs/guides/write-file/unlink.md
parent67599f97adc77141331a5f4fc39e4d058dc70b2a (diff)
downloadbun-404b90badc5856a74c06d04062c850003e28fed5.tar.gz
bun-404b90badc5856a74c06d04062c850003e28fed5.tar.zst
bun-404b90badc5856a74c06d04062c850003e28fed5.zip
Add ecosystem guides (#3847)
* Add ecosystem guides * Update titles * Rename stric * Add unlink and fetch guides * Add formdata guide * Tweak title * Moar
Diffstat (limited to 'docs/guides/write-file/unlink.md')
-rw-r--r--docs/guides/write-file/unlink.md23
1 files changed, 23 insertions, 0 deletions
diff --git a/docs/guides/write-file/unlink.md b/docs/guides/write-file/unlink.md
new file mode 100644
index 000000000..ba0cbe8b1
--- /dev/null
+++ b/docs/guides/write-file/unlink.md
@@ -0,0 +1,23 @@
+---
+name: Delete a file
+---
+
+To synchronously delete a file with Bun, use the `unlinkSync` function from the [`node:fs`](https://nodejs.org/api/fs.html#fs_fs_unlink_path_callback) module. (Currently, there is no `Bun` API for deleting files.)
+
+```ts
+import { unlinkSync } from "node:fs";
+
+const path = "/path/to/file.txt";
+unlinkSync(path);
+```
+
+---
+
+To remove a file asynchronously, use the `unlink` function from the [`node:fs/promises`](https://nodejs.org/api/fs.html#fs_fspromises_unlink_path) module.
+
+```ts
+import { unlink } from "node:fs/promises";
+
+const path = "/path/to/file.txt";
+await unlink(path);
+```