horas
Version:
A simple CLI app to manage local daily tasks notation files.
23 lines (22 loc) • 555 B
JavaScript
import fs from 'fs';
export function readFile(file_path, notFound) {
try {
return fs.readFileSync(file_path, {
encoding: 'utf-8'
}) || notFound || '';
}
catch (err) {
return notFound || '';
}
}
export function writeFile(file_path, textData) {
fs.writeFileSync(file_path, textData, {
encoding: 'utf-8'
});
}
export function exists(file_path) {
return fs.existsSync(file_path);
}
export function mkdir(file_path, recursive = true) {
fs.mkdirSync(file_path, { recursive: true });
}