UNPKG

@kadena/kadena-cli

Version:

Kadena CLI tool to interact with the Kadena blockchain (manage keys, transactions, etc.)

67 lines 1.65 kB
import fsSync from 'fs'; import fs from 'node:fs/promises'; export const fileSystemService = { readFileSync(path) { try { return fsSync.readFileSync(path, 'utf8'); } catch (e) { return null; } }, async readFile(path) { try { return await fs.readFile(path, 'utf8'); } catch (e) { return null; } }, async writeFile(path, data) { await fs.writeFile(path, data, 'utf8'); }, async deleteFile(path) { await fs.unlink(path); }, async deleteDirectory(path) { await fs.rm(path, { recursive: true }); }, async directoryExists(path) { try { const stat = await fs.stat(path); return stat.isDirectory(); } catch { return false; } }, async fileExists(path) { try { const stat = await fs.stat(path); return stat.isFile(); } catch { return false; } }, async ensureDirectoryExists(directory) { if (await fileSystemService.directoryExists(directory)) return; await fs.mkdir(directory, { recursive: true, }); }, async readDir(path) { return fs.readdir(path); }, async readDirWithTypes(path) { return fs.readdir(path, { withFileTypes: true }); }, async appendFile(path, data) { await fs.appendFile(path, data, { encoding: 'utf8' }); }, async lstat(path) { return fs.lstat(path); }, }; //# sourceMappingURL=fs.service.js.map