3.0.3 • Published 7 months ago

@manuth/temp-files v3.0.3

Weekly downloads
206
License
MIT
Repository
-
Last release
7 months ago

TempFiles

Provides the functionality to handle temporary files and directories the object-oriented way.

status-badge

Installing TempFiles

TempFiles can be installed using the npm-cli:

npm install --save @manuth/temp-files

Using TempFiles

You can create temporary filesystem-entries by initializing new instances of the TempFile- or the TempDirectory-class.
Temporary filesystem-entries easily can be removed by invoking TempFileSystem.Dispose().

When working with a TempDirectory you can use TempDirectory.MakePath(...string[]) to create paths relative to the directory.

Example

import fs = require("fs");
import { TempDirectory, TempFile } from "@manuth/temp-files";

let tempDir = new TempDirectory();
let tempFile = new TempFile(
    {
        postfix: ".json"
    });

let fileName = tempDir.MakePath("this", "is", "a", "test.txt");
fs.writeFileSync(fileName, "Hello World");
fs.writeFileSync(tempFile.FullName, '{ "Message": "Hello World" }');

tempFile.Dispose();
tempDir.Dispose();