Skip to main content
Home

Built and signed on GitHub Actions

🦕 Create a temporary sandbox directory and temporary move into it

This package works with DenoIt is unknown whether this package works with Cloudflare Workers, Node.js, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
94%
Published
a week ago (3.0.1)

sandbox

JSR Test codecov

This module provides sandbox() and sandboxSync() function to create a temporary sandbox directory.

Usage

import { sandbox, sandboxSync } from "@lambdalisue/sandbox";

{
  await using sbox = await sandbox();
  // Create files in the sandbox directory using sbox.resolve()
  await Deno.writeTextFile(sbox.resolve("foo.txt"), "Hello");
  const content = await Deno.readTextFile(sbox.resolve("foo.txt"));
}
// The sandbox directory is automatically removed here

{
  using sbox = sandboxSync();
  // Create files in the sandbox directory using sbox.resolve()
  Deno.writeTextFileSync(sbox.resolve("bar.txt"), "World");
  const content = Deno.readTextFileSync(sbox.resolve("bar.txt"));
}
// The sandbox directory is automatically removed here

Note: This module does not change the current working directory. This design allows parallel test execution without interference. Use sbox.resolve(path) to get absolute paths within the sandbox directory.

License

The code follows MIT license written in LICENSE. Contributors need to agree that any modifications sent in this repository follow the license.

Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@lambdalisue/sandbox

Import symbol

import * as sandbox from "@lambdalisue/sandbox";
or

Import directly with a jsr specifier

import * as sandbox from "jsr:@lambdalisue/sandbox";

Add Package

pnpm i jsr:@lambdalisue/sandbox
or (using pnpm 10.8 or older)
pnpm dlx jsr add @lambdalisue/sandbox

Import symbol

import * as sandbox from "@lambdalisue/sandbox";

Add Package

yarn add jsr:@lambdalisue/sandbox
or (using Yarn 4.8 or older)
yarn dlx jsr add @lambdalisue/sandbox

Import symbol

import * as sandbox from "@lambdalisue/sandbox";

Add Package

vlt install jsr:@lambdalisue/sandbox

Import symbol

import * as sandbox from "@lambdalisue/sandbox";

Add Package

npx jsr add @lambdalisue/sandbox

Import symbol

import * as sandbox from "@lambdalisue/sandbox";

Add Package

bunx jsr add @lambdalisue/sandbox

Import symbol

import * as sandbox from "@lambdalisue/sandbox";