@folkforms/file-io
v0.2.12
Published
A few simple file IO functions.
Downloads
46
Readme
file-io
A single package for file IO that combines fs-extra
, fast-glob
, untildify
and ignore
.
glob(pattern, options)
- Globs all files according to the given pattern and returns an array of the file paths. This is a thin wrapper around fast-glob.ignore(files, rootFolder, ignoreFile)
: Remove files from a list based on the set of ignore files present inrootFolder
and subfoldersreadLines(path)
- Reads a text file into an array of linesreadLinesAsString(path)
- Reads a text file into a single stringreadJson(path)
- Reads a text file and parses it as JSON. Equivalent to callingJSON.parse(readLines(path))
.writeLines(path, array, append = false)
- Writes the given array of lines (joined with"\n"
) to a filecopyFolder(inputFolder, outputFolder, options)
- Copies the given folder recursively, preserving directory structure. Options are the options used when globbing up the input folder. See fast-glob options.exists(path)
- Checks if the given path existsrm_rf(path)
- Removes the given file, or else removes the given folder and its contents recursivelymkdir_p(path)
- Creates the given folder and any required intermediate folderscp(src, dest)
- Copies a file to a file or folder