Created
December 18, 2024 20:53
-
-
Save Vehmloewff/cc4c7d9944739a39974f5e1f2fd723bd to your computer and use it in GitHub Desktop.
Run a typescript function directly
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
#!/bin/bash | |
filepath=$1 | |
funcname=$2 | |
[[ $filepath != *.ts ]] && filepath="$filepath.ts" | |
dataurl='data:text/typescript,import { '$funcname' } from "file://'$(pwd)'/'$filepath'";console.log(await '$funcname'());' | |
deno run -A "$dataurl" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Install it like so:
Then, assuming a
foo.ts
file exists in the cwd and that it exports abar
function, run it like so: