diff --git a/typescript-deno/.tool-versions b/typescript-deno/.tool-versions new file mode 100644 index 0000000..776e434 --- /dev/null +++ b/typescript-deno/.tool-versions @@ -0,0 +1 @@ +deno 2 diff --git a/typescript-deno/README.md b/typescript-deno/README.md index 0675ad6..48facad 100644 --- a/typescript-deno/README.md +++ b/typescript-deno/README.md @@ -2,23 +2,26 @@ Skeleton project for TypeScript with testing via [Deno](https://deno.land/). -Make sure you have Deno installed by running `deno --version`. +## Prerequisites -If using VSCode, you might want to enable the extension in the settings: +The toolchain this project needs is declared in [`.tool-versions`](./.tool-versions): -```jsonc -// .vscode/settings.json -{ - "deno.enable": true, - // or specifically - "deno.enablePaths": ["./typescript-deno"] -} +``` +deno 2 +``` + +Install those however you prefer, as long as they end up on your `PATH`. The quickest route is +[mise](https://mise.jdx.dev/), which reads the file for you: + +```sh +mise install ``` ## Usage -- `./script/start` to run the source code -- `./script/test` to run the tests in watch mode +- `./script/setup` to fetch dependencies +- `./script/test` to run the tests, or `./script/test --watch` to re-run them on every change +- `./script/start` to run the app ## Structure @@ -26,3 +29,16 @@ If using VSCode, you might want to enable the extension in the settings: - Tests located in [`mod.test.ts`](./src/mod.test.ts) However, you are free to organise your code as you like. + +## VSCode + +If using VSCode, you might want to enable the Deno extension in the settings: + +```jsonc +// .vscode/settings.json +{ + "deno.enable": true, + // or specifically + "deno.enablePaths": ["./typescript-deno"] +} +``` diff --git a/typescript-deno/script/setup b/typescript-deno/script/setup new file mode 100755 index 0000000..0ca8275 --- /dev/null +++ b/typescript-deno/script/setup @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -euo pipefail + +cd "$(dirname "${BASH_SOURCE[0]}")/.." + +deno cache src/mod.test.ts diff --git a/typescript-deno/script/start b/typescript-deno/script/start index b0d1a3e..ab53f08 100755 --- a/typescript-deno/script/start +++ b/typescript-deno/script/start @@ -1,5 +1,7 @@ #!/usr/bin/env bash -set -e +set -euo pipefail + +cd "$(dirname "${BASH_SOURCE[0]}")/.." deno run src/mod.ts diff --git a/typescript-deno/script/test b/typescript-deno/script/test index f3f2ab4..e7d024f 100755 --- a/typescript-deno/script/test +++ b/typescript-deno/script/test @@ -1,6 +1,8 @@ #!/usr/bin/env bash -set -e +set -euo pipefail + +cd "$(dirname "${BASH_SOURCE[0]}")/.." if [[ "${1:-}" == "--watch" ]]; then deno test src --watch