sandbox
This module provides sandbox()
function to create a temporary sandbox
directory. The Sandbox
instance returned by sandbox()
has a lot of
manipulation methods for files/directories in the temporary directory.
Note that the sandbox instance is Disposable
thus uses can use using()
function provided by disposable
module to ensure
that the sandbox temporary directory is cleaned up.
Usage
import { sandbox } from "https://deno.land/x/sandbox/mod.ts";
import { using } from "https://deno.land/x/disposable/mod.ts";
await using(await sandbox(), async (sbox) => {
// Create a file 'foo' in the sandbox
const f = await sbox.create("foo");
// Do what ever you want
});
// The sandbox directory is removed here.
See sandbox_test.ts
for examples.
License
The code follows MIT license written in LICENSE. Contributors need to agree that any modifications sent in this repository follow the license.