Created
March 27, 2020 00:18
-
-
Save thgaskell/20d209a5da49be7a01933ec86d7ae908 to your computer and use it in GitHub Desktop.
Hello, Deno!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { parse } from "https://deno.land/std/flags/mod.ts"; | |
function greet(name?: string): void { | |
if (!name) { | |
console.log('Hello, World!'); | |
} else { | |
console.log(`Hello, ${name}!`); | |
} | |
} | |
const { name } = parse(Deno.args); | |
greet(name); |
If you just want to use the latest version of the script, you can omit the commit hash (before the file name).
Usage
$ deno run https://gist.githubusercontent.com/thgaskell/20d209a5da49be7a01933ec86d7ae908/raw/main.ts --name Deno
Hello, Deno!
You can use the deno install
command to save the file as an executable:
$ deno install hello-deno https://gist.githubusercontent.com/thgaskell/20d209a5da49be7a01933ec86d7ae908/raw/main.ts
Download https://gist.githubusercontent.com/thgaskell/20d209a5da49be7a01933ec86d7ae908/raw/main.ts
Compile https://gist.githubusercontent.com/thgaskell/20d209a5da49be7a01933ec86d7ae908/raw/main.ts
Download https://deno.land/std/flags/mod.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
Download https://deno.land/std/testing/format.ts
✅ Successfully installed hello-deno
After that, you may be prompted to add the deno binary path to your $PATH
variable. Once your shell script resolves the deno binary path, you should be able to run the command with your chosen executable name:
$ hello-deno
Hello, World!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just trying out executing deno script from a URL ✨
Usage (
--name John
flag is included)