Skip to content

Add temporaryFiles() resource API with using/await using support and upgrade CI to Node 22#23

Open
Copilot wants to merge 4 commits into
mainfrom
copilot/add-using-keyword-support
Open

Add temporaryFiles() resource API with using/await using support and upgrade CI to Node 22#23
Copilot wants to merge 4 commits into
mainfrom
copilot/add-using-keyword-support

Conversation

Copilot AI commented May 25, 2026

Copy link
Copy Markdown
Contributor

This change adds explicit resource management support while preserving the existing callback-based usingTemporaryFiles(...) API. The library can now be consumed directly with the TC39 using model via disposable/async-disposable resource objects.

  • New ERM entrypoint

    • Added temporaryFiles() that returns the same file operations (add, addDirectory, path, read, remove) plus disposal hooks:
      • asyncDispose and [Symbol.asyncDispose]
      • dispose and [Symbol.dispose]
  • Shared lifecycle + backward compatibility

    • Refactored temp directory creation/cleanup into shared internals used by both temporaryFiles() and usingTemporaryFiles(...).
    • Kept existing promise/callback behavior intact; no migration required for current consumers.
  • Disposal semantics

    • Disposal is idempotent.
    • Sync and async disposal paths converge on shared cleanup coordination so repeated or mixed disposal calls do not leak resources or double-delete.
  • Docs + type surface

    • Updated README with explicit-resource-management usage.
    • Updated generated dist artifacts (.js and .d.ts) to include the new API surface.
  • CI/Release runtime update

    • Updated GitHub Actions workflows to run on Node 22.x, the first Node major with explicit resource management support without a flag.
    • Replaced deprecated ::set-output usage with $GITHUB_OUTPUT in workflows.
import { temporaryFiles } from "using-temporary-files";

await using files = temporaryFiles();
await files.add("file.txt", "hello");
const text = await files.read("file.txt");

@changeset-bot

changeset-bot Bot commented May 25, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 45e96a6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copilot AI linked an issue May 25, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add support for using keyword in explicit resource management Add temporaryFiles() resource API with using/await using support May 25, 2026
Copilot AI requested a review from pmcelhaney May 25, 2026 21:27
@pmcelhaney pmcelhaney marked this pull request as ready for review May 25, 2026 21:28
@pmcelhaney

Copy link
Copy Markdown
Owner

@copilot upgrade node in CI to the first version that supports explicit resource management without a flag

Copilot AI commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

@copilot upgrade node in CI to the first version that supports explicit resource management without a flag

Done in 45e96a6.

  • Updated CI to run on Node 22.x (the first Node major with explicit resource management support without a flag).
  • Updated release workflow to Node 22.x as well.
  • Replaced deprecated set-output usage with $GITHUB_OUTPUT in both workflows.

Copilot AI changed the title Add temporaryFiles() resource API with using/await using support Add temporaryFiles() resource API with using/await using support and upgrade CI to Node 22 Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Explicit resource management (using keyword)

2 participants