From 45f9b32ef0416e0477e9f5335df49ca3cccdb6eb Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Sun, 10 May 2020 03:09:42 +0200 Subject: 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. --- docs/examples/file_server.md | 22 ++++++++++++++++++++++ docs/examples/file_system_events.md | 18 ++++++++++++++++++ docs/examples/fileserver.md | 22 ---------------------- docs/examples/tcp_echo.md | 2 +- docs/examples/unix_cat.md | 2 +- 5 files changed, 42 insertions(+), 24 deletions(-) create mode 100644 docs/examples/file_server.md create mode 100644 docs/examples/file_system_events.md delete mode 100644 docs/examples/fileserver.md (limited to 'docs/examples') diff --git a/docs/examples/file_server.md b/docs/examples/file_server.md new file mode 100644 index 000000000..9fbe27bd3 --- /dev/null +++ b/docs/examples/file_server.md @@ -0,0 +1,22 @@ +## File server + +This one serves a local directory in HTTP. + +```shell +deno install --allow-net --allow-read https://deno.land/std/http/file_server.ts +``` + +Run it: + +```shell +$ file_server . +Downloading https://deno.land/std/http/file_server.ts... +[...] +HTTP server listening on http://0.0.0.0:4500/ +``` + +And if you ever want to upgrade to the latest published version: + +```shell +$ file_server --reload +``` 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/fileserver.md b/docs/examples/fileserver.md deleted file mode 100644 index 3ed9d90e7..000000000 --- a/docs/examples/fileserver.md +++ /dev/null @@ -1,22 +0,0 @@ -## File server - -This one serves a local directory in HTTP. - -```bash -deno install --allow-net --allow-read https://deno.land/std/http/file_server.ts -``` - -Run it: - -```shell -$ file_server . -Downloading https://deno.land/std/http/file_server.ts... -[...] -HTTP server listening on http://0.0.0.0:4500/ -``` - -And if you ever want to upgrade to the latest published version: - -```shell -$ file_server --reload -``` 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 ``` -- cgit v1.2.3