@minimaz/core
v0.3.1
Published
Filesystem utilities (path checks, JSON reads, copy/remove/output helpers) shared across the Minimaz ecosystem.
Readme
@minimaz/core
Filesystem utilities (path checks, JSON reads, copy/remove/output helpers) shared across the Minimaz ecosystem.
Install
npm install @minimaz/coreUsage
import { pathExists, readJsonFile, outputFile, copy, remove } from '@minimaz/core'
if (await pathExists('minimaz.config.json')) {
const config = await readJsonFile<Record<string, unknown>>('minimaz.config.json')
}
await outputFile('dist/index.html', '<html></html>')API
pathExists(path)— whether a path exists.readJsonFile<T>(file)— reads andJSON.parses a file.getDirElements(dir)— lists a directory's entries.isDirectory(path)— whether a path is a directory.getFileContent(path)— reads a file as UTF-8 text; rejects with aKnownError(original error ascause) if it can't be read.copy(src, dest, overwrite?)— copies a file or directory.remove(path)— removes a file or directory.ensureDir(path)— creates a directory (and parents) if missing.outputFile(path, data, options?)— writes a file, creating parent directories first.- Re-exports
basename,dirname,extname,isAbsolute,join,normalize,resolvefromnode:path.
Depends on @minimaz/logger.
