UNPKG

redis-smq-common

Version:

RedisSMQ Common Library provides many components that are mainly used by RedisSMQ and RedisSMQ Monitor.

33 lines 864 B
import axios from 'axios'; import fs from 'fs'; import { access, constants, mkdir } from 'node:fs/promises'; export async function doesPathExist(filePath) { try { await access(filePath, constants.F_OK); return true; } catch { return false; } } export async function ensureDirectoryExists(dirPath) { try { await access(dirPath, constants.F_OK); } catch { await mkdir(dirPath, { recursive: true }); } } export async function downloadFile(url, savePath) { const response = await axios({ url, responseType: 'stream', }); const writer = fs.createWriteStream(savePath); response.data.pipe(writer); return new Promise((resolve, reject) => { writer.on('finish', resolve); writer.on('error', reject); }); } //# sourceMappingURL=filesystem.js.map