This provides a number of utility modules to make it easier working with directories and files in a node.js project.
Install badger-filesystem
using your favourite package manager.
npm add @abw/badger-filesystem
pnpm add @abw/badger-filesystem
yarn add @abw/badger-filesystem
Visit the website for documentation and examples.
import { dir } from '@abw/badger-filesystem'
// a config directory
const config = dir('config');
// check it exists and create it if not
await config.mustExist({ create: true });
// create a JSON file in the directory
const hello = config.file('hello.json', { codec: 'json' });
// write some data to it
await hello.write({ message: 'Hello World!' });
// read data from it
const data = await hello.read();
Andy Wardley https://github.com/abw