Sha256: d34560fed7be090f0fc61bb9ef9be64aa2e23019f96d1cb9b20ebb627ac9c28c

Contents?: true

Size: 1.11 KB

Versions: 25

Compression:

Stored size: 1.11 KB

Contents

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withTempFile = void 0;
const promises_1 = __importDefault(require("fs/promises"));
const os_1 = __importDefault(require("os"));
const path_1 = __importDefault(require("path"));
// Invokes the given handler with the path to a temporary file. The file
// is deleted after the handler returns.
const withTempFile = async (handler) => withTempDir(async (dir) => handler(path_1.default.join(dir, 'tempfile')));
exports.withTempFile = withTempFile;
// Invokes the given handler with a temporary directory. The directory is
// deleted after the handler returns.
const withTempDir = async (handler) => {
    const tmpDir = await promises_1.default.realpath(os_1.default.tmpdir());
    const dir = await promises_1.default.mkdtemp(tmpDir + path_1.default.sep);
    try {
        return await handler(dir);
    }
    finally {
        await promises_1.default.rm(dir, { force: true, recursive: true, maxRetries: 3 });
    }
};

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
immosquare-cleaner-0.1.52 node_modules/tuf-js/dist/utils/tmpfile.js
immosquare-cleaner-0.1.51 node_modules/tuf-js/dist/utils/tmpfile.js
immosquare-cleaner-0.1.50 node_modules/tuf-js/dist/utils/tmpfile.js
immosquare-cleaner-0.1.49 node_modules/tuf-js/dist/utils/tmpfile.js
immosquare-cleaner-0.1.48 node_modules/tuf-js/dist/utils/tmpfile.js
immosquare-cleaner-0.1.47 node_modules/tuf-js/dist/utils/tmpfile.js
immosquare-cleaner-0.1.46 node_modules/tuf-js/dist/utils/tmpfile.js
immosquare-cleaner-0.1.45 node_modules/tuf-js/dist/utils/tmpfile.js
immosquare-cleaner-0.1.44 node_modules/tuf-js/dist/utils/tmpfile.js
immosquare-cleaner-0.1.43 node_modules/tuf-js/dist/utils/tmpfile.js
immosquare-cleaner-0.1.42 node_modules/tuf-js/dist/utils/tmpfile.js
immosquare-cleaner-0.1.41 node_modules/tuf-js/dist/utils/tmpfile.js
immosquare-cleaner-0.1.40 node_modules/tuf-js/dist/utils/tmpfile.js
immosquare-cleaner-0.1.39 node_modules/tuf-js/dist/utils/tmpfile.js
immosquare-cleaner-0.1.38 node_modules/tuf-js/dist/utils/tmpfile.js
immosquare-cleaner-0.1.32 node_modules/tuf-js/dist/utils/tmpfile.js
immosquare-cleaner-0.1.31 node_modules/tuf-js/dist/utils/tmpfile.js
immosquare-cleaner-0.1.30 node_modules/tuf-js/dist/utils/tmpfile.js
immosquare-cleaner-0.1.29 node_modules/tuf-js/dist/utils/tmpfile.js
immosquare-cleaner-0.1.28 node_modules/tuf-js/dist/utils/tmpfile.js