summaryrefslogtreecommitdiff
path: root/docs/examples
diff options
context:
space:
mode:
authorLuca Casonato <lucacasonato@yahoo.com>2020-05-10 03:09:42 +0200
committerGitHub <noreply@github.com>2020-05-10 03:09:42 +0200
commit45f9b32ef0416e0477e9f5335df49ca3cccdb6eb (patch)
treeb04cab2d36b39932320f9e95537910b8742f32f7 /docs/examples
parentf6b617784f53497b0c59d6f6f1370cb2223e38f3 (diff)
Docs for deno test + minor other changes (#5185)
* Added fs events example. * Added docs for `deno test`. * Renamed file server example. * Unified markdown code types. * Removed plugin topics from TOC. * Fixed links.
Diffstat (limited to 'docs/examples')
-rw-r--r--docs/examples/file_server.md (renamed from docs/examples/fileserver.md)2
-rw-r--r--docs/examples/file_system_events.md18
-rw-r--r--docs/examples/tcp_echo.md2
-rw-r--r--docs/examples/unix_cat.md2
4 files changed, 21 insertions, 3 deletions
diff --git a/docs/examples/fileserver.md b/docs/examples/file_server.md
index 3ed9d90e7..9fbe27bd3 100644
--- a/docs/examples/fileserver.md
+++ b/docs/examples/file_server.md
@@ -2,7 +2,7 @@
This one serves a local directory in HTTP.
-```bash
+```shell
deno install --allow-net --allow-read https://deno.land/std/http/file_server.ts
```
diff --git a/docs/examples/file_system_events.md b/docs/examples/file_system_events.md
new file mode 100644
index 000000000..2abebc33e
--- /dev/null
+++ b/docs/examples/file_system_events.md
@@ -0,0 +1,18 @@
+### File system events
+
+To poll for file system events:
+
+```ts
+const watcher = Deno.watchFs("/");
+for await (const event of watcher) {
+ console.log(">>>> event", event);
+ // { kind: "create", paths: [ "/foo.txt" ] }
+}
+```
+
+Note that the exact ordering of the events can vary between operating systems.
+This feature uses different syscalls depending on the platform:
+
+- Linux: inotify
+- macOS: FSEvents
+- Windows: ReadDirectoryChangesW
diff --git a/docs/examples/tcp_echo.md b/docs/examples/tcp_echo.md
index d7c2e9e72..360c5facc 100644
--- a/docs/examples/tcp_echo.md
+++ b/docs/examples/tcp_echo.md
@@ -25,7 +25,7 @@ For security reasons, Deno does not allow programs to access the network without
explicit permission. To allow accessing the network, use a command-line flag:
```shell
-$ deno run --allow-net https://deno.land/std/examples/echo_server.ts
+deno run --allow-net https://deno.land/std/examples/echo_server.ts
```
To test it, try sending data to it with netcat:
diff --git a/docs/examples/unix_cat.md b/docs/examples/unix_cat.md
index 7534ef0d0..ca85ea325 100644
--- a/docs/examples/unix_cat.md
+++ b/docs/examples/unix_cat.md
@@ -20,5 +20,5 @@ I/O streams in Deno.
Try the program:
```shell
-$ deno run --allow-read https://deno.land/std/examples/cat.ts /etc/passwd
+deno run --allow-read https://deno.land/std/examples/cat.ts /etc/passwd
```