UNPKG

@mondaycom/apps-cli

Version:

A cli tool to manage apps (and monday-code projects) in monday.com

30 lines (29 loc) 836 B
import { promises as fs } from 'node:fs'; import logger from './logger.js'; export class FSError extends Error { constructor(message) { super(message); this.message = message; } } export const saveToFile = async (filePath, content) => { try { await fs.writeFile(filePath, content, 'utf8'); } catch (error) { logger.debug(error); throw new FSError(`Failed to save file, please check if this file path "${filePath}" is correct.`); } }; export const loadFile = (filePath) => { try { return fs.readFile(filePath, 'utf8'); } catch (error) { logger.debug(error); throw new FSError(`Failed to load file, please check if this file path "${filePath}" is correct.`); } }; export const unlink = async (path) => { await fs.unlink(path); };