docs/toolbox-filesystem.md
A set of functions & values to work with files and directories. The majority of these functions come
straight from fs-jetpack, a fantastic API for working with the
file system. All jetpack-based functions have an equivalent *Async version if you need it.
You can access these tools on the Gluegun toolbox, via const { filesystem } = require('gluegun'), or directly via const { filesystem } = require('gluegun/filesystem').
This value is the path separator \ or / depending on the OS.
toolbox.filesystem.separator // '/' on posix but '\' on windows
This value is the end of line byte sequence.
toolbox.filesystem.eol // '\n' on posix but '\r\n' on windows
This function retrieves the path to the home directory.
toolbox.filesystem.homedir() // '/Users/jh' on my macOS machine
Finds the immediate subdirectories in a given directory.
toolbox.filesystem.subdirectories(`~/Desktop`) // []
Appends data to the end of a file.
Changes directory ownership. See more in the fs documentation.
Copies a file or a directory.
Gets the current working directory.
Ensures a directory exists and creates a new jetpack
instance with it's cwd pointing there.
Checks to see if file or directory exists.
Finds files or directories.
Grabs information about a file or directory.
Grabs nested information about a set of files or directories.
Gets a directory listing, like ls.
Moves files and directories.
Grabs path parts as a string.
Reads the contents of a file as a string or JSON.
Deletes a file or directory.
Renames a file or directory.
Resolves a sequence of paths or path segments into an absolute path.
Makes a symbolic link to a file or directory.
Writes data to a file.