UNPKG

@dfinity/pic

Version:

An Internet Computer Protocol canister testing library for TypeScript and JavaScript.

28 lines 890 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.exists = exists; exports.tmpFile = tmpFile; exports.readFileAsBytes = readFileAsBytes; exports.readFileAsString = readFileAsString; const promises_1 = require("node:fs/promises"); const node_path_1 = require("node:path"); const node_os_1 = require("node:os"); async function exists(filePath) { try { await (0, promises_1.access)(filePath, promises_1.constants.F_OK); return true; } catch (e) { return false; } } function tmpFile(filePath) { return (0, node_path_1.resolve)((0, node_os_1.tmpdir)(), filePath); } async function readFileAsBytes(filePath) { return await (0, promises_1.readFile)(filePath); } async function readFileAsString(filePath) { return await (0, promises_1.readFile)(filePath, { encoding: 'utf-8' }); } //# sourceMappingURL=fs.js.map