Library functions to seamlessly generate directories and files at the specified
path using a JavaScript object that maps to the desired filesystem tree.
Includes support for the
ES Explicit Resource Management
spec and
using
keyword.
await genFs({
"dist/index.html": "<h1>Hello genFs!</h1>",
"dist/styles.css": "* { font-size: 2rem; }",
"dist/main.js": "console.log('hello world')",
}, { rootDir: "dist" });
Creates the following:
.
└── dist
├── index.html
├── main.js
└── styles.css
async function run() {
await using tmpFs = await genFs({
"dist": {
"css/main.css": "",
"js/main.js": ""
"index.html": ""
}
}, { rootDir: "dist", cleanup: true });
// ... do something ...
// Removes `dist/` before returning
}
This package also exports genTmpFs
that automatically creates a temp dir where
your filesystem is generated and cleans up afterward via using
keyword.
Deno.test("my test", async () => {
await using tmpFs = await genTmpFs({
"dist/index.html": "<h1>Hello genFs!</h1>",
"dist/styles.css": "* { font-size: 2rem; }",
"dist/main.js": "console.log('hello world')",
});
console.log(tmpFs.tmpDir);
// ACT
// Removes the tmp dir before returning
});
- Add documentation via JSDoc comments
- Add more test cases
- Make package compatible with node/bun
- Publish to JSR and npm
- Chores
- Add git hooks to fmt/lint check
- Enforce conventional commits
- Setup CI for PRs
- Setup CI/CD for publishing using semantic release (or equivalent)