Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use deno for typescript and ts code blocks #47

Open
brandonkal opened this issue Mar 17, 2020 · 2 comments
Open

Use deno for typescript and ts code blocks #47

brandonkal opened this issue Mar 17, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@brandonkal
Copy link

Deno is a secure TypeScript runtime written in rust.

I propose that typescript code blocks use Deno to execute.
It handles dependency fetching and compiling TypeScript to JavaScript automatically. This means a maskfile.md can be self contained, there is no need to run an npm install to make the JavaScript blocks function.

Because Deno requires permission flags to operate, there would need to be a way to provide permission arguments to the deno run invocation.

@jacobdeichert
Copy link
Owner

jacobdeichert commented Mar 17, 2020

Brilliant... assigning ts/typescript lang code to deno definitely makes sense to me with the current state of things. I was wondering how to add deno support, and this solves it 👍

Regarding deno permission args, I'm open to suggestions. Perhaps the first line of the codeblock could define which args to pass.. as a comment to keep it simple.

## deno_cmd
~~~ts
// --allow-read --allow-write     etc...
console.log('this is denoooo');
~~~

@jacobdeichert jacobdeichert added the enhancement New feature or request label Mar 17, 2020
@brandonkal
Copy link
Author

Yes. Deno permissions are hard. For ref here is how you can do it with a shebang. It looks rather ugly because -S isn't supported well outside macOS.

One thing I've been doing with my deno files is adding file-level JSDoc comments for copyright, author, description. I then parse that to generate my README.md. I've considered adding denoargs in there but abandoned that idea as it is not JSDoc standard.

So you could have:

/** 
 * @author brandonkal
 * @donoargs --allow-read --allow-write
 */

That gets too repetitive though.

What I would suggest is this:

// run: [allow-read, allow-write]

That line would have to be within the top 5 lines of the code block. A string may be better than an array, but ideally it would also be parsable as YAML for other tools. With explicit allow reads etc it would need to handle multiple lines:

// run: >
//   --allow-read=/a/very/long------path/project/foo
//   --allow-write=/a/very/long------path/project/foo

console.log('this is denoooo')

When you need multiple lines though, array syntax is easier to manage to my eye.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants