KO
|
EN
gitlite — search
Search
#typescript
#ai-agents
#ai
#dsh-plugin
#deepseek-harness
#open-source
#cli
#claude-code
#codex
#developer-tools
#react
#windows
leaf
★ 45
Open GitHub ↗
A fake file system for Deno binaries
Download README (.md)
Explore Similar Repositories
smui-example-sveltekit
:
SMUI SvelteKit Example
dbgr
:
Lightweight debugger for Node.js
Sveltekit-Typescript-TailwindCSS-Jit
:
A template project that combines SvelteKit, TypeScript and TailwindCSS (JIT mode)
rust-hack-and-learn
:
Coordination repository for the remote "Hack & Learn" event
hasura-supertokens
:
Open source implementation of Supertokens with Hasura
// repository documentation
Was this content helpful?
★ 0
(0 ratings)
Select Rating:
★
★
★
★
★
Submit Feedback
Recent Feedback
×
Download README
Do you want to download the
README.md
file for
leaf
?
Download (.md)
# Leaf [](https://github.com/mandarineorg/leaf) <img src="https://www.mandarinets.org/assets/images/full-logo-simple.svg" width="180" height="180" /> A fake file system for [Deno](https://deno.land) binaries by [Mandarine](https://deno.land/x/mandarinets). ------------ ## Description Leaf is a fake file system for Deno binaries. This means, you can save your files along with the binary generated by `deno compile`, this way, you can put all your files together in a single executable which leads to easier deployments and a more compacted deliverable output. ## Usage Using **Leaf** in your application is very simple, you just use the regular Deno APIs after you ran a 'leaf compile'. More on this below. ### leaf compile step. The `Leaf.compile()` method is responsible for creating a typescript file with your resources in it. This file is then compiled into your binary. `Leaf.compile()` takes one argument containing the options to include. ```typescript // File: compile.ts import { Leaf } from "https://deno.land/x/leaf/mod.ts"; Leaf.compile({ modulePath: "./myEntryPoint.ts", contentFolders: ["./resources"], // flags: [], // output: '' }) ``` `modulePath` and `contentFolders` are necessary. - `modulePath`: File to be compiled into a binary. - `contentFolders`: Folders to be attached to the binary. - `flags` *optional*: the Deno flags normally used for `deno compile`. - `output` *optional*: Replaces the `--output` flags option. ### readFileSync Synchronously reads and returns the entire contents of a file as an array of bytes. `TextDecoder` can be used to transform the bytes to string if required. Reading a directory returns an empty data array. ```typescript const decoder = new TextDecoder("utf-8"); const data = Deno.readFileSync("hello.txt"); console.log(decoder.decode(data)); ``` ### readFile Reads and returns the entire contents of a file as an array of bytes. `TextDecoder` can be used to transform the bytes to string if required. Reading a directory returns an empty data array. ```typescript const decoder = new TextDecoder("utf-8"); const data = await Deno.readFile("hello.txt"); console.log(decoder.decode(data)); ``` ### readTextFileSync Synchronously reads and returns the entire contents of a file as utf8 encoded string. ```typescript const data = Deno.readTextFileSync("hello.txt"); console.log(data); ``` ### readTextFile Reads and returns the entire contents of a file as utf8 encoded string. ```typescript const data = await Deno.readTextFile("hello.txt"); console.log(data); ``` ----------------- ## Example ### Compile the binary We **run** the `compile.ts` script which creates the file system `.ts` which then runs `deno compile` to build the final binary. ```typescript // compile.ts import { Leaf } from "https://deno.land/x/leaf/mod.ts"; Leaf.compile({ modulePath: "./myEntryPoint.ts", contentFolders: ["./resources"] }) ``` _./resources/hello.txt_ ```text Hello World ``` _myEntryPoint.ts:_ ```typescript console.log(Deno.readTextFileSync("./resources/hello.txt")); ``` ```shell deno run --allow-all --unstable compile.ts ``` ```shell ./myEntryPoint (.exe if windows) # output: Hello World ``` ----------------- ## Questions For questions & community support, please visit our [Discord Channel](https://discord.gg/qs72byB) or join us on our [twitter](https://twitter.com/mandarinets). ## Want to help? ### Interested in coding In order to submit improvements to the code, open a PR and wait for it to review. We appreciate you doing this. ### Not interested in coding We would love to have you in our community, [please submit an issue](https://github.com/mandarineorg/leaf/issues) to provide information about a bug, feature, or improvement you would like. ## Follow us wherever we are going - Author : [Andres Pirela](https://twitter.com/andreestech) - Website : https://www.mandarinets.org/ - Twitter : [@mandarinets](https://twitter.com/mandarinets) - Discord : [Click here](https://discord.gg/qs72byB)