summaryrefslogtreecommitdiff
path: root/docs/linking_to_external_code.md
diff options
context:
space:
mode:
authorChris Knight <cknight1234@gmail.com>2020-06-10 18:43:44 +0100
committerGitHub <noreply@github.com>2020-06-10 13:43:44 -0400
commit1120dfe3f2d5732eb2eda0996726efd33554e42c (patch)
tree71609ded4e26f747f2f7d873f641bc3911f65159 /docs/linking_to_external_code.md
parentbe8bacaaa4258089e5a0cf4f1d8f53db8e534d4b (diff)
doc: improve linking to external code docs (#6158)
Diffstat (limited to 'docs/linking_to_external_code.md')
-rw-r--r--docs/linking_to_external_code.md12
1 files changed, 8 insertions, 4 deletions
diff --git a/docs/linking_to_external_code.md b/docs/linking_to_external_code.md
index af46faf5d..ad6cfab09 100644
--- a/docs/linking_to_external_code.md
+++ b/docs/linking_to_external_code.md
@@ -4,13 +4,15 @@ In the [Getting Started](./getting_started.md) section, we saw Deno could
execute scripts from URLs. Like browser JavaScript, Deno can import libraries
directly from URLs. This example uses a URL to import an assertion library:
+**test.ts**
+
```ts
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
assertEquals("hello", "hello");
assertEquals("world", "world");
-console.log("Asserted! 🎉");
+console.log("Asserted! ✓");
```
Try running this:
@@ -21,15 +23,15 @@ Compile file:///mnt/f9/Projects/github.com/denoland/deno/docs/test.ts
Download https://deno.land/std/testing/asserts.ts
Download https://deno.land/std/fmt/colors.ts
Download https://deno.land/std/testing/diff.ts
-Asserted! 🎉
+Asserted! ✓
```
Note that we did not have to provide the `--allow-net` flag for this program,
and yet it accessed the network. The runtime has special access to download
imports and cache them to disk.
-Deno caches remote imports in a special directory specified by the `$DENO_DIR`
-environment variable. It defaults to the system's cache directory if `$DENO_DIR`
+Deno caches remote imports in a special directory specified by the `DENO_DIR`
+environment variable. It defaults to the system's cache directory if `DENO_DIR`
is not specified. The next time you run the program, no downloads will be made.
If the program hasn't changed, it won't be recompiled either. The default
directory is:
@@ -58,6 +60,8 @@ For example, let's say you were using the above assertion library across a large
project. Rather than importing `"https://deno.land/std/testing/asserts.ts"`
everywhere, you could create a `deps.ts` file that exports the third-party code:
+**deps.ts**
+
```ts
export {
assert,